#include #include class Person { protected : // data members char* _name; public : // member functions virtual ~Person() { printf("Person::~Person()\n"); } Person(char* name) { _name = name; printf("Person::Person()\n"); } virtual void eat() { printf("Person::eat()\n"); } void shit() { printf("Person::shit()\n"); } }; class Man : public Person { public : // member functions virtual ~Man() { printf("Man::~Man()\n"); } Man(char* name) : Person(name) { printf("Man::Man()\n"); } virtual void eat() { printf("Man::eat()\n"); } void shit() { printf("Man::shit()\n"); } }; class Woman : public Person { public : // member functions virtual ~Woman() { printf("Woman()::~Woman()\n"); } Woman(char* name) : Person(name) { printf("Woman::Woman()\n"); } virtual void eat() { printf("Woman::eat()\n"); } void shit() { printf("Woman::shit()\n"); } }; void main() { Man *aMan = new Man("Kim Taegyun"); Woman *aWoman = new Woman("Choi Jinshil"); Person *aPerson = aMan; aPerson->eat(); aPerson = aWoman; aPerson->eat(); aPerson = aMan; aPerson->shit(); aPerson = aWoman; aPerson->shit(); delete aMan; delete aWoman; }