64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class c
{
public:
c(){i = 0;j = 0;}
c(int x,int y){i = x,j = y;}
c a(c t)
{
cout << "i = " << i << endl;
cout << "t.i = " << t.i << endl;
cout << "j = " << j << endl;
cout << "t.j = " << t.j << endl;
}
private:
int i,j;
};
int main()
{
c t1(1,1),t2(2,2),t3;
t3 = t1.a(t2);
return 0;
}
c a(c t)
{
cout << "i = " << i << endl;
cout << "t.i = " << t.i << endl;
cout << "j = " << j << endl;
cout << "t.j = " << t.j << endl;
return *this;
}