Purchase Solution

C++ Inheritance

Not what you're looking for?

Ask Custom Question

Write a C++ program with 4 classes called A,B,C and D. D should inherit C, C should inherit B and B should inherit A. All classes should have 1 data member of type int, 1 constructor and 1 function called print. The constructor should initialize the data member to a rand() value. The print function should display the data member on the screen.

In the main function, try to access the print functions using only an object of class D.

Purchase this Solution

Solution Summary

Attached program demonstrates how one can access print functions of different direct and indirect base classes of class D (apart from accessing the print function of class D), using only an object of class D.

Purchase this Solution


Free BrainMass Quizzes
Basic Networking Questions

This quiz consists of some basic networking questions.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Javscript Basics

Quiz on basics of javascript programming language.

C# variables and classes

This quiz contains questions about C# classes and variables.