64,637
社区成员
发帖
与我相关
我的任务
分享
Class Test
{
Test ( cosnt Test &);
Test &operator=(const Test &);
}
void main()
{
Test one;
Test two = one;
}
Test one;
Test three;
Test two = one;//创建了对象 two
three = two;//调用的是赋值重载函数。
#include <iostream>
using namespace std;
class A
{
public:
A(){}
A(const A&single)
{
cout<<"hello"<<endl;
}
A & operator = (const A &single)
{
cout<<"world"<<endl;
}
};
int main()
{
A one;
A two = one;
//two = one;
return 0;
}