Written by Sai Sandeep Thota on April 1, 2013 in C++ > Programming

What is Multiple Inheritance?

GET ALERTS:

Get our Latest updates delivered to your mailbox!

Multiple inheritance is that in which a class inherits the features from two Base classes when a Derived Class takes Features from two Base Classes. What is Inheritance? You can understand What is Multiple Inheritance by taking a look at the program below.

multiple-inheritance

#include<conio.h>
#include<iostream.h>

class base1 {
	protected:
	int x;
	public:
	void showx() {
		cout<<"\nx="<<x;
	}
};

class base2 {
	protected:
	int y;
	public:
	void showy() {
		cout<<"\ny="<<y;
	}
};

class derived:public base1, public base2 {
	public:
	void setxy(int i, int j) {
	x=i;
	y=j;
	}
};

void main() {
	derived ob1;
	clrscr();
	ob1.setxy(10,20);
	ob1.showx();
	ob1.showy();
	getch();
}

Output:
Multiple_Inheritance

Comments on this entry are closed.

Previous post:

Next post: