深拷贝和浅拷贝
摘要:
浅拷贝(当遇到指针变量时会出错!!)#include "iostream"using namespace std;class A{public: A() { x=new int; *x=5; } ~A() { delete x; x=NULL; } A(const A&a) { cout<<"拷贝构造函数执行中"<<endl; x=new int; *x=*(a.x); } void print() { cout<<*x<<endl; } void set(int i) { *x=i; }priva 阅读全文
posted @ 2012-08-29 10:21
++小客
阅读(125)
评论(0)
推荐(0)
浙公网安备 33010602011771号