Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a program to create three classes A , B , and C . Class B is derived from class A , and class

C++

Write a program to create three classes A, B, and C. Class B is derived from class A, and class C is derived from Class B. Use the member access specifier public when inheriting the classes. Each of these classes have a public method called print().

  1. The print() method of class A has a statement to print This is class A.
  2. The print() method of class B has a statement to print This is class B.
  3. The print() method of class C has a statement to print This is class C.

In your main program, create an object of class C, called objC and call the method print() of objC. It should print This is class C. What you just did is function overriding, where a method of a child class is hiding the methods of its parent classes.

Now, write statements to call methods print() of class B and C using objC.

Add another method in class A called localA(). The localA() has one statement to print, This is local method of A. Call localA() method using objC in your main 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

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

2. How can competencies be used in employee development?

Answered: 1 week ago