Question: a ) Define a base class called Shape. The Shape class should have the following members: Protected Member Variable: id ( double ) A constructor

a) Define a base class called Shape. The Shape class should have the following members:
Protected Member Variable: id (double)
A constructor with parameter a. It should set the value of member id with a.
Public virtual function: print. This function will print "Polymorphism".
b) Define a class named Circle. It should be derived from the Shape class and have following members:
A constructor with parameter c. It should call the base class constructor to set the value of member id with c.
A print function that overrides the print function in the base class. This function should call base class's print function and also print the data member id.
c) After you have created these classes, create a test piveram (containing main()) that does the following
defines a Circle object with id 10.
declares a Shape pointer. The Shape pointer will point to object of class Circle.
uses the Shape pointer to invoke print function.
d) State the output of the program.
 a) Define a base class called Shape. The Shape class should

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!