// esim3.cpp #include #include using namespace std; class Mother { public: Mother() { cout << "Mother-muodostin" << endl; } ~Mother() { cout << "Mother-hajotin" << endl; } void puhu() { cout << "Kulta-pieni mussukka!" << endl; } }; class Baby : public Mother { public: Baby() { cout << "Baby-muodostin" << endl; } ~Baby() { cout << "Baby-hajotin" << endl; } void puhu() { cout << "Laa laa laa!" << endl; } }; int main(void) { Mother *pMamma = new Mother(); Mother *pVaavi = new Baby(); // "vaavi on eräänlainen mamma" if (pMamma) { pMamma->puhu(); delete pMamma; } if (pVaavi) { pVaavi->puhu(); delete pVaavi; } return (0); }