Make sure two points : 1 copy all member variable 2 call the copy function of all base classes
Class Customer{public:explicit Customer (const tstring _name,const tstring _lasttransaction): M_sname (_name), m_ Slasttransaction (_lasttransaction) {OutputDebugString (_t ("Customer construct \ n")); Virtual ~customer () {OutputDebugString (_t ("Customer deconstruct \ n")); Customer (const customer& customer): M_sname (customer.m_sname) {OutputDebugString (_t ("Customer copy construct \ n") );} customer& operator= (const customer& customer) {m_sname = customer.m_sname;outputdebugstring (_T ("Customer operater \ n ")); return *this;} Private:tstring m_sname;tstring m_slasttransaction;}; Class Prioritycustomer:public customer{public:explicit Prioritycustomer (const tstring name,const tstring LastTime,int npriority): M_npriority (npriority), Customer (name, lasttime) {OutputDebugString (_t ("Prioritycustomer construct \ n")) ;} Prioritycustomer (const prioritycustomer& RHS): m_npriority (rhs.m_npriority), Customer (RHS) {OutputDebugString (_ T ("Prioritycustomer copy construct\n");} prioritycustomer& operator= (cOnst Prioritycustomer RHS) {OutputDebugString (_t ("Prioritycustomer operater \ n")); m_npriority = rhs.m_npriority; Customer::operator= (RHS); return *this;} Virtual ~prioritycustomer () {OutputDebugString (_t ("Prioritycustomer deconstruct \ n")); Private:int m_npriority;};
C + + Copy objects don't forget every part