C++ Program to find Area and Volume using Multiple inheritance

By | January 2, 2017

Area and Volume using multiple inheritance


Write a C++ Program to find Area and Volume using Multiple inheritance. Here’s a Simple C++ Program to find Area and Volume using Multiple inheritance in C++ Programming Language.


Multiple Inheritance : :


When a class is inherited from more than one base class, it is known as multiple inheritance.

  • The syntax for defining a subclass, which is inheriting more than one classes is:

    class Subclass : access_specifier   Baseclass1,

access_specifier    Baseclass2,   ………

         ……..    access_specifier    Baseclass_n

{

members of the derived class ;

};

  • The following figure example shows the use of multiple inheritance.
  • Circle and Rectangle are two base classes from which the class Cylinder is being inherited.
  • The data members of both the base classes are declared in protected mode. Thus, the class Cylinder can access the data member radius of class Circle and data member length, breadth of the class Rectangle, but the objects of the class Cylinder cannot access these protected data members.
  • The volume of the cylinder is equal to 22/7*(radius*radius*length). Thus, instead of defining these data again, they can be inherited from the base classes Circle and Rectangle ( radius from class Circle and length from class Rectangle ).

Below is the source code for C++ Program to demonstrate an Example of Multilevel Inheritance which is successfully compiled and run on Windows System to produce desired output as shown below :


SOURCE CODE : :



OUTPUT : :



Above is the source code and output for C++ Program to demonstrate an Example of Multilevel Inheritance which is successfully compiled and run on Windows System to produce desired output.

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach upto you in the short interval.


Thanks for reading the post….

Leave a Reply