Question: Write a program that has the following properties: /////////////////////// need solve in a different way ///////////////////////////// A class named Class_1 with a constructor which initializes

Write a program that has the following properties: /////////////////////// need solve in a different way /////////////////////////////

  1. A class named Class_1 with a constructor which initializes two protected member variables of the class. This class consists of a virtual function named calc() which returns the addition of the member variables. And the last member of the class is a function named show(int) to print the parameter. Both the function should be of public type.
  2. A class Class_2 which derives the Class_1 and overrides the calc() for returning the subtraction of the derived member variables.
  3. A class Class_3 which derives the Class_2 and overrides the calc() for returning the multiplication of the derived member variables.
  4. The main() function which creates objects of the classes. Using base classs pointer, print the returned value of each classs calc() function calling the show() function of the base class.

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!