Purchase Solution

A C++ example of classes and inheritance

Not what you're looking for?

Ask Custom Question

Write a C++ program that uses 7 classes following a tree inheritance structure.

The base class must also have a virtual print() function that displays the class name.

Randomly assign print functions in three other classes that display the class name.

Create 7 pointers of the base class and have them point to all the classes.

Use the pointers to call print functions of all classes.

Purchase this Solution

Solution Summary

This solution provides a simple example of class inheritance in C++. It also illustrates the difference between virtual and non-virtual overridden methods.

Solution Preview

We will start by creating an inheritance structure where each class has two subclasses. The diagram looks like following:

A
/
B C
/ /
D E F G

The virtual ...

Purchase this Solution


Free BrainMass Quizzes
Architectural History

This quiz is intended to test the basics of History of Architecture- foundation for all architectural courses.