#include<iostream>
using namespace std;
class Complex1
{
private:
int a, b;
public:
Complex1(Complex1 &obj){
this->a = obj.getA();
this->b = obj.getB();
cout <<
"我是copy 构造函数" <<
"a:" << a <<
"\t b:" << b << endl;
}
Complex1(
int a =
0,
int b =
0)
{
this->a = a;
this->b = b;
}
int getA(){
return a;
}
int getB(){
return b;
}
void show(){
cout <<
"a:" << a <<
"\t b:" << b << endl;
}
friend Complex1
operator+(Complex1 &c1, Complex1 &c2);
friend Complex1
operator++(Complex1 &c1);
Complex1
operator-(Complex1 &c1)
{
Complex1 tmp;
tmp.a =
this->a - c1.a;
tmp.b =
this->b - c1.b;
return tmp;
}
Complex1
operator --(){
this->a--;
this->b--;
return *
this;
}
friend Complex1
operator++(Complex1 &c2,
int);
};
Complex1
operator ++ (Complex1 &c2,
int)
{
Complex1 tmp;
tmp = c2;
c2.a++;
c2.b++;
return tmp;
}
Complex1
operator+(Complex1 &c1, Complex1 &c2)
{
Complex1 tmp;
tmp.a = c1.a + c2.a;
tmp.b = c1.b + c2.b;
return tmp;
}
Complex1
operator ++(Complex1 &c1)
{
c1.a++;
c1.b++;
return c1;
}
Complex1 g(){
Complex1 c1;
return c1;
}
void main(){
Complex1 c1(
10,
20), c2(
3,
4);
Complex1 c3 = c1.
operator-(c2);
c3.show();
c3++;
c3.show();
c3--;
c3.show();
c3.
operator--();
c3.show();
--c3;
c3.show();
Complex1 c4 = c3++;
c4.show();
c3.show();
system(
"pause");
}