拷贝构造函数即构造某一类型,下面所示只是拷贝构造函数的声明,其定义形式
如:A::A(const A& test): a(test.a);
class A{
public:
A(); //默认构造函数
A(const A&); //拷贝构造函数
private:
int a;
};
//拷贝赋值运算符,即让两个类型相等
//如: A a,b;
// a=b;
A& A::operate=(const A &test){
a=test.a;
return *this
}