class Complex
{
public:
Complex(int r, int i):
real(r),
imagine(i)
{}
Complex() :
real (0),
imagine (0)
{}
void Print()
{
std::cout << "real: " << real << " imagine: " << imagine << "\n";
}
private:
int real, imagine;
};
#include <iostream>
class Complex
{
public:
Complex(int r, int i):
real(r),
imagine(i)
{}
Complex() :
real (0),
imagine (0)
{}
void Print()
{
std::cout << "real: " << real << " imagine: " << imagine << "\n";
}
//copy constructor
Complex(const Complex& rhs)
{
real = rhs.real;
imagine = rhs.imagine;
}
//overload operator +
Complex operator + (const Complex& rhs)
{
Complex res;
res.real = real + rhs.real;
res.imagine = imagine + rhs.imagine;
return res;
}
//overload operator -
Complex operator - (const Complex& rhs)
{
Complex res;
res.real = real - rhs.real;
res.imagine = imagine - rhs.imagine;
return res;
}
//overload operator =
void operator = (const Complex& rhs)
{
real = rhs.real;
imagine = rhs.imagine;
}
//overload operator <<
//destructor
~Complex()
{
}
private:
int real, imagine;
};