Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 /////////////////////////////
- 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.
- A class Class_2 which derives the Class_1 and overrides the calc() for returning the subtraction of the derived member variables.
- A class Class_3 which derives the Class_2 and overrides the calc() for returning the multiplication of the derived member variables.
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started