SOLUTION:
#include "stdafx.h"
#include "iostream"
using namespace std;
/////////////////////////////////////////////////////////////////////////////////////////
class Int
{
private:
long
i;
public:
Int(
) :i(0) { /*Empty Body*/ }
Int(int
n) :i(n) { /*Empty Body*/ }
void
display( Int obj2, Int obj3, char ch ) const
{ cout << obj2.i << ch
<< obj3.i << " = " << i << endl; }
Int
operator + (Int) const; Int
operator - (Int) const;
Int
operator * (Int) const; Int
operator / (Int) const;
};
//---------------------------------------------------------------------------------------
Int Int::operator + (Int temp) const
{ long r; r = i+temp.i; return
Int(r); }
Int Int::operator - (Int temp) const
{ long r; r = i-temp.i; return Int(r); }
Int Int::operator * (Int temp) const
{ long r; r = i*temp.i; return
Int(r); }
Int Int::operator / (Int temp) const
{ long r; r = i/temp.i; return
Int(r); }
/////////////////////////////////////////////////////////////////////////////////////////
void main( )
{
Int
first, second(250), third(122);
first =
second+third; first.display(
second,third,'+' );
first =
second-third; first.display(
second,third,'-' );
first =
second*third; first.display(
second,third,'*' );
first =
second/third; first.display(
second,third,'/' );
system("pause");
}
OUTPUT:
0 comments: