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 It should set the value of member id with
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 It should call the base class constructor to set the value of member with
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
c After you have created these classes, create a test piveram containing main that does the following
defines a Circle object with id
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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
