Social Icons

banner image

multiple inheritancs

Multiple Inheritance in C++

In C++ programming, a class can be derived from more than one parents. For example: A classRectangle is derived from base classes Area and Circle.
Example of multiple inheritance in C++ programming language

Source Code to Implement Multiple Inheritance in C++ Programming

#include<iostream.h>
#include<conio.h>
class first
{
      int a;
      public:
             void get()
             {
                  cin>>a;}
                 int disp()
                 {return a;}
};
class second
{
      int b;
      public:
             void getsec(){
                  cin>>b;
                  }
                int  dispsec()
                  {
                      return b;}
                 
};
class third:public first,public second
{
public:
       void getfinal()
       {
            get();
            getsec();
            }
            void dispfinal()
            {
                 cout<<"ans="<<disp()+dispsec();
                 }
                 
};
main()
{
      third t1;
      t1.getfinal();
      t1.dispfinal();
      getch();
      }
multiple inheritancs multiple inheritancs Reviewed by Shobhit Goel on May 05, 2015 Rating: 5

No comments:

Airtel Hackaton 2017

Powered by Blogger.