C++ 拷贝构造函数 copy ctor & 拷贝赋值函数 copy op=

类中含有  指针类型  的成员变量时,就必须要定义 copy ctor 和 copy op=

 

copy ctor 请见:

class Rectangle
{
public:
	Rectangle(Rectangle& rec)
		: width(rec.width), height(rec.height)
	{};

	~Rectangle() {};

public:
	int width;
	int height;
};

  

 

copy op= 请见:

https://www.cnblogs.com/alexYuin/p/11965172.html

 

posted @ 2019-12-01 15:13  路边的十元钱硬币  阅读(325)  评论(0编辑  收藏  举报