Multiple Inheritance in C++

Multiple Inheritance in C++

Multiple Inheritance in C++

Multiple Inheritance: In this type of inheritance a single derived class may inherit from two or more than two base classes.

 

SYNTAX :

class A
{ 
... .. ... 
};
class B
{
... .. ...
};
class C: public A,public B
{
... ... ...
};

 

 

CODE :

#include<iostream.h>
class A
{
public:
int a;
void getA()
{
cout<<“Enter an Integer value”<<endl;
cin>>a;
}
};
class B
{
public:
int b;
void getB()
{
cout<<“Enter an Integer value”<<endl;
cin>>b;
}
};

class C:public A,public B
{
public:
int c;
void add()
{
c=a+b;
cout<<a<<“+”<<b<<“=”<<c<<endl;
}
};
int main()
{
C obj;
obj.getA();
obj.getB();
obj.add();
}

 

OUTPUT :

Enter an Integer
value 12 Enter an
Integer value 13
12+13=25

 


 

Topics Covered :

 

  • inheritance in c++
  • ย multiple inheritance in c++
  • multiple inheritance in hindi
  • types of inheritance
  • c++ inheritance
  • c++ object oriented programming

 

 


 

 


 

Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.

Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.

 

๐Ÿง‘โ€๐Ÿ’ป๐Ÿง‘โ€๐Ÿ’ปย Social Mediaย Linksย ofย Tech DCodeย :

๐Ÿ‘‰๐Ÿปย YouTube :ย https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
๐Ÿ‘‰๐Ÿปย Instagram :ย https://www.instagram.com/thetechdcode/
๐Ÿ‘‰๐Ÿปย Facebook Page :ย https://www.facebook.com/thetechdcode
๐Ÿ‘‰๐Ÿปย Twitter :ย https://twitter.com/thetechdcode
๐Ÿ‘‰๐Ÿปย Telegram Channel :ย https://t.me/thetechdcode
๐Ÿ‘‰๐Ÿปย Tech DCode Linktree :ย https://linktr.ee/thetechdcode
๐Ÿ‘‰๐Ÿปย My Personal Handles :ย https://linktr.ee/virtualshivamin

๐Ÿง‘โ€๐Ÿ’ป๐Ÿง‘โ€๐Ÿ’ปย Social Media Linksย ofย SHIVAM SINGHย (OWNER) :

๐Ÿ‘‰๐Ÿปย Instagram :ย https://www.instagram.com/virtualshivamin/
๐Ÿ‘‰๐Ÿปย Facebook Page :ย https://www.facebook.com/virtualshivamin/
๐Ÿ‘‰๐Ÿปย Twitter :ย https://twitter.com/virtualshivamin/
๐Ÿ‘‰๐Ÿปย Personal Linktree :ย https://linktr.ee/virtualshivaminย 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *