摘要:
声明时,初始化=操作,()操作都是调用拷贝构造函数,只有初始化完成后,=操作才是operator=,示例:Type a;Type b(a); // 拷贝构造函数Type a;Type b = a; // 拷贝构造函数Type a;Type b;b = a; // operator=(Type&)由于operator=和拷贝构造函数功能几乎一样,通常管理深拷贝成员,实现1个operator=就行class Type{ const Type& operator= (const Type& right) { if (this == &right) ... 阅读全文
posted @ 2011-11-03 17:22
asight
阅读(953)
评论(0)
推荐(0)
浙公网安备 33010602011771号