Multiple Inheritance in C++

C++ version 2.0 was released by AT&T during the summer of 1989, and the major addition to the language is multiple inheritance, the ability to inherit data and methods from more than one class into a subclass. Multiple inheritance and a few of the other additions to the language will be discussed in this chapter along with some of the expected future directions of the language.

Several companies have C++ compilers available in the marketplace, and many others are sure to follow. Because the example programs in this tutorial are designed to be as generic as possible, most should be compilable with any good quality C++ compiler provided it follows the AT&T definition of version 2.1 or newer. Many of these examples will not work with earlier definitions because the language was significantly changed with the version 2.1 update.

Multiple Inheritance in C++

C++ Language’s most powerful feature is multiple inheritance which makes it more powerful than Java.

It is possible for one class to inherit the attributes of two or more classes.

The general form is

Here is a simple example.

Here Z class has the access to both the members of X & Y class.

2 Comments

  1. Write a program which overloads a binary Minus (-) operator,
    The program will contain a class Matrix, This class will contain a private data member Array[][] which store int values. The class will further contain a Default constructor, get() function which takes values for array from the user and also contain a Display function witch display the array on the screen,
    In main function create three objects Mat1, Mat2, Mat3 of this class, first call get() and Display() functions with Mat1 and Mat2 objects then implement the statement Mat3 = Mat1 – Mat2; and call Display() function with Mat3.

Leave a Reply