Answered step by step
Verified Expert Solution
Link Copied!

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 /////////////////////////////

  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

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_2

Step: 3

blur-text-image_3

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

What are the social tasks and challenges of adolescence?

Answered: 1 week ago