Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Here is a C code example for creating a base class called Person with a virtual function called ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Primer Plus

Authors: Stephen Prata

6th Edition

978-0321776402, 0321776402

More Books

Students also viewed these Algorithms questions

Question

What is a default constructor? What is the advantage of having one?

Answered: 1 week ago