拷贝构造函数

1.标准格式:X::(const X &)

2.使用情况 :A:当用一个对象去初始化同类的一个对象时

      B:作为函数形参

      C:作为函数返回值

3.易错点:

#include<iostream>

using namespace std;

class Test
{
    
};

int main()
{
      Test t1;
      Test t2(t1);
      Test t3;
      t3=t1;//不调用拷贝构造函数,只复制对应值
      return 0;    
}
原文地址:https://www.cnblogs.com/-Asurada-/p/10656758.html