Question: 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
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 program (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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
