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

猜你喜欢

转载自www.cnblogs.com/alexYuin/p/11966155.html
今日推荐