class TestA{ public: TestA() { a = new int; } ~TestA() { delete a; } int *a; }; class TestB : public TestA{ public: TestB() { b = new int; } TestB(const TestB& B) { b = new int; *b = *B.b; } ~TestB() { delete b; } int *b; }; main() { TestB a; TestB b = a; }