#include #define NIL (0) int key[5] = { 0, 1, 2, 3, 4 }; // key °ª ´ëÄ¡ class Person { public: int x; Person() { } virtual void doingX(Person *spouse = NIL); void doingY(Person *spouse = NIL); }; class Man : public Person { public: Man() { } virtual void doingX(Person *spouse = NIL); void doingY(Person *spouse = NIL); }; class Woman : public Person { public: Woman() { } virtual void doingX(Person *spouse = NIL); void doingY(Person *spouse = NIL); }; void Person::doingX(Person *spouse) { printf("%d\n",key[0]); if (spouse != NIL) { spouse->doingX(); } } void Person::doingY(Person *spouse) { printf("%d\n",key[1]); if (spouse != NIL) { spouse->doingY(); } } void Man::doingX(Person *spouse) { printf("%d\n",key[2]); if (spouse != NIL) { spouse->doingX(); } } void Man::doingY(Person *spouse) { printf("%d\n",key[3]); if (spouse != NIL) { spouse->doingY(); } } void Woman::doingX(Person *spouse) { printf("%d\n",key[4]); if (spouse != NIL) { spouse->doingX(); } } void Woman::doingY(Person *spouse) { printf("%d\n",key[0]); if (spouse != NIL) { spouse->doingY(); } } void main() { Man *adam = new Man(); Woman *eve = new Woman(); adam->doingX(eve); eve->doingX(eve); adam->doingY(eve); }