A very common mistake
#endif /* __BADPARENT_H__ */
class child : public badparent {
pointer = new int [1024];
cout << " in child's constructor" << endl;
cout << " in child's destructor" << endl;
“child” is doing all by the books: all memory allocated is freed again in the destructor. We print messages so that we can see the constructor and destructor being called.
looks ok (and is ok) -- for each constructor called, we call the destructor, all fine.
So why is the parent “bad”?