C++ program – implement three classes using multiple inheritance

by Nideesh C on April 14, 2011 · 0 comments

in C++




Write a program to illustrating how all the three classes are implemented in multiple inheritance mode.

	#include<iosteram.h>
	#include<conio.h>
 
	Class M
        {
		Protected:
		Int m;
		Public :
		Void get_M();
	};
	Class N
        {
		Protected:
		Int n;
		Public:
		Void get_N();
	};
	Class p: public M, public N
	{
		Public:
		Void disply(void);
	};
	Void M ::get_m(int x)
	{
		m=x;
	}
	Void N::get_n(int y)
	{
		n=y;
	}
	Void P:: disply(void)
	{
	Cout<<”m=”<<m<<endl;
	Cout<<”n=”<<n<<endl;
	Cout<<”m*n=”<<m*n<<endl;
	}
	int main()
	{
		P p;
		p.get_m(10);
		p.get_n(20);
		p.display();
		return 0;
	}

OUTPUT

m=10

n=20
m*n=200



Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C++ program – Using class to generate mark sheet using multiple inheritance
  2. C++ program – illustrate Hybrid Inheritance.
  3. C++ program to implement Hash Table
  4. C++ program – implement Pure Virtual Functions
  5. C++ program to implement Heap sort Algorithm

Leave a Comment

Previous post:

Next post: