C++ program to implement three classes using multiple inheritance

Saturday, March 13th, 2010

MULTIPLE INHERITANCES

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

ALGORITHM
• Start the process
• Invoke the class M
• Invoke the another class N
• Invoke one more class,ie class P,which is inherited by both M and N
• Create an object for class p,ie P p
• Call p.get_m(),assign the value in to ‘m’
• Call p.get_n(),assign the value in to ‘n’
• Call display(), for dispay the result
• Stop the result

PROGRAM:

	#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

Avatar of Ranjith

Author Name :
Ranjith

Total : 8 Comments


8 Responses to “C++ program to implement three classes using multiple inheritance”

  1. sukhjeet says:

    programss have errors

  2. mahendra says:

    In given code there is many error. If you run this program then you will find near about 16 error when it’s compile.

  3. Pankhudhi says:

    MIND YOU BUT C++ IS A CASE SENSITIVE LANGUAGE AND ARE REQUIRED ONLY TO USE THE LOWER CASE ALPHABETS..
    SO IN THIS CASE THE PROGRAM GENERATES ERRORS.

  4. n.vijay says:

    i need c++ program , hybrid inheritance using payroll

  5. n.vijay says:

    i need c++ program , e-bill using file

  6. n.vijay says:

    i need c++ program payroll system using multiple inheritance

  7. A.Wana says:

    Thank you sir.This program is beneficial for me. I need more programs using inheritance.

  8. suvarna says:

    i need c++ prog for base class name,d.o.b,blood group,data member height,wt,&derived class tel ph no.,drivinh licence no. i]build a master table ii]display iii]insert a new entry iv] delete entry v]edit vi] search for a record with description.
    thanks a lot.

Leave a Reply

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: