Question: Create a base class called Person with a virtual function called display(). Create two derived classes called Student and Teacher. Override the display() function in
Create a base class called Person with a virtual function called display(). Create two derived classes called Student and Teacher. Override the display() function in both derived classes to print "I am a student" and "I am a teacher", respectively. In the main() function, create a pointer of type Person and assign it to an object of Student. Call the display() function using the pointer. Next, assign the pointer to an object of Teacher and again call the display() function.
Step by Step Solution
3.43 Rating (156 Votes )
There are 3 Steps involved in it
Here is a C code example for creating a base class called Person with a virtual function called ... View full answer
Get step-by-step solutions from verified subject matter experts
