class A
{
private:
int a;
int b;
public:
A(int a, int b)
{
this->a = a;
this->b = b;
}
A Test(A &aa)
{
A temp = A(this->a + aa.a, this->b + aa.b);
cout << temp.a << "b:" << temp.b << endl;
return temp;
}
A &Test1(A &Aa)
{
this->a = this->a + Aa.a;
this->b = this->b + Aa.b;
return *this;
}
void print()
{
cout << this->a << "b:" << this->b << endl;
}
};
void main()
{
A a1(1, 2);
A a2(3, 4);
a1.Test1(a2);
//a2.Test(a1);
a1.print();
system("pause");
}
面向对象,全局函数和成员函数之间的转换
原文:https://www.cnblogs.com/jefy/p/9404388.html