Virtual Functions: Syntax
virtual char *print_sex(void) { cout << “I’m a generic person\n”; };
virtual char *print_sex(void) { cout << “I’m a female\n”; };
virtual char *print_sex(void) { cout << “I’m a male\n”; }
for (int i = 0; i < 3; i++)
Without virtual, all three print statements will print “I’m a generic person”. With virtual, the three statements will report being generic, female, and male.