Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions