#include #include #include using namespace std; class CNum{ public: CNum(){ pi_num = new int(); *pi_num=11; } CNum(CNum &other){ pi_num = new int(*other.pi_num); } ~CNum(){ if(pi_num!=NULL) delete pi_num; } int iGetVal(){ return *pi_num; } CNum operator + (CNum &other){ CNum result; *result.pi_num=*pi_num+*other.pi_num; return result; } void operator = (int val){ *pi_num=val; } private: int *pi_num; }; int main() { CNum c_t0, c_t1, c_t2; cout< #include using namespace std; class CTab{ public: CTab(){ pi_tab=new int(); size=0; } ~CTab(){if(pi_tab!=NULL) delete pi_tab;} void vSetSize(int iSize){ delete pi_tab; size=iSize; pi_tab=new int[iSize]; } CTab(const CTab &COther){ size=COther.size; pi_tab=new int[size]; for (int i=0; i #include #include using namespace std; class CNode{ public: CNode(int val){ pi_val=new int(val); } CNode(CNode &other){ pi_val=new int(*other.pi_val); for(int i=0; ivPrint(); } } private: int *pi_val; vector v_kids; }; class CTree{ public: CTree(){ pc_root=new CNode(0); } CTree(CTree &other){ pc_root=new CNode(*other.pc_root); } ~CTree(){ delete pc_root; } CNode *pcGetRt(){ return pc_root; } void vPrint(){ pc_root->vPrint(); } private: CNode *pc_root; }; int main() { CTree c_t0; c_t0.pcGetRt()->vSetVal(1); c_t0.pcGetRt()->vAdd(new CNode(2)); CNode *pc_buf; pc_buf = new CNode(3); pc_buf->vAdd(new CNode(4)); c_t0.pcGetRt()->vAdd(pc_buf); c_t0.vPrint(); CTree *pc_copy = new CTree(c_t0); pc_copy->vPrint(); delete pc_copy; }*/