#include
class CComleex
{
double m_real;
double m_image;
public:
void setValue(double real,double image)
{
m_real=real;
m_image=image;
}
friend ostream& operator<<(ostream& out, CComleex& oc);
friend CComleex operator+(CComleex& oc1, CComleex& oc2);
friend CComleex& operator++(CComleex& oc);
friend CComleex operator++(CComleex& oc, int);
};
ostream& operator<<(ostream& out, CComleex& oc)
{
out <
}
CComleex operator+(CComleex& oc1, CComleex& oc2)
{
CComleex tmp;
tmp.m_real=oc1.m_real+oc2.m_real;
tmp.m_image=oc1.m_image+oc2.m_image;
return tmp;
}
CComleex& operator++(CComleex& oc)
{
++oc.m_real;
++oc.m_image;
return oc;
}
CComleex operator++(CComleex& oc, int)
{
CComleex tmp(oc);
oc.m_real++;
oc.m_image++;
return tmp;
}
int main(){
CComleex c1,c2,c3,c4,c5,c6,c7;
c1.setValue(1,5);
c2.setValue(3.5,2.5);
c3.setValue(4.5,6.5);
c4.setValue(4.5,6.5);
c5=c1+c2;
cout <<"c1: " <
cout <<"c6=++c3: " <
cout <<"c7=c4++: " <
}