摘要: 1 class Empty 2 { 3 public: 4 Empty(); 5 Empty(const Empty&); 6 ~Empty(); 7 Empty & operator =(const Empty &); 8 Empt... 阅读全文
posted @ 2014-09-26 21:13 hana12169 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 主要有一下四种方式1.Bpublic继承自A;calss B : public A{ ... }2.在A中写参数为B的复制构造函数calss A{ A(const B &b); }3.重写A的=operatorA & operator(const B& ); 阅读全文
posted @ 2014-09-26 20:55 hana12169 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 深拷贝和浅拷贝的根本区别是变量和指针内存申请方式的不同导致的,如果对一一个变量则不存在深拷贝和浅拷贝的区别,对于一些类中包含指针的需要进行动态分配内存的进行拷贝的时候会有深拷贝和浅拷贝的区别事例如下: 1 #include 2 3 using namespace std; 4 5 class C... 阅读全文
posted @ 2014-09-26 20:04 hana12169 阅读(308) 评论(0) 推荐(0) 编辑