#include using namespace std; class a{ public: int *x; // default constructor a():x(new int[10]){ for(int i = 0; i < 10; i++) x[i]=i+1; } // copy constructor a(a &z){ x = new int[10]; for(int i = 0; i < 10; i++) x[i] = z.x[i]; } // without copy constructor deletes twice blows up ~a(){delete []x;} }; void main(){ a test, test2(test); test2.x[0] = 17; /* demonstration of using deleted memory int *p = new int(3); cout << *p << endl; delete p; cout << *p << endl; p = 0; cout << *p << endl; */ // without copy constructor prints 17 cout << test.x[0] << endl; }