65,211
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class A
{
int i,j;
public:
A(){cout <<"A()" <<endl;}
A(int a,int b){i=a;j=b;cout <<"A(int,int)" <<endl;}
A(A & a)
{
i = a.i;
j = a.j;
cout <<"A(A&a)" <<i <<"" <<j <<endl;
}
friend A operator + (A a,A b);
};
A operator+ (A a,A b)
{
return A(a.i+ b.i,a.j+b.j);
}
int main()
{
return 0;
}
//lz用的是vc6.0吧??这是微软的一个欠佳的地方!!头文件换换就行了
#include <iostream.h>
//using namespace std;
class A
{
int i,j;
public:
A(){cout <<"A()" <<endl;}
A(int a,int b){i=a;j=b;cout <<"A(int,int)" <<endl;}
A(A & a)
{
i = a.i;
j = a.j;
cout <<"A(A&a)" <<i <<"" <<j <<endl;
}
friend A operator+(const A& a,const A& b);
};
A operator+(const A& a,const A& b)
{
return A(a.i+ b.i,a.j+b.j);
}
int main()
{
return 0;
}