13.1.2 拷贝赋值运算符

来源:互联网 发布:淘宝群词荟萃 编辑:程序博客网 时间:2024/06/06 14:12

拷贝构造函数即构造某一类型,下面所示只是拷贝构造函数的声明,其定义形式

如: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}

 
原创粉丝点击