C++ program to implement three classes using multiple inheritance

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;
	}

Start exploring endless computing possibilities with your own Raspberry Pi computer and accessories. Perfect for beginners and students.

OUTPUT

m=10
n=20
m*n=200


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

  1. mahendra

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

    Reply
    • Frankie

      I have an iPad, but found in recent times I have migrated towards a laptop as a secondary machine. The touch screen is great, but it;812#7&s the keyboard that has pulled me to the laptop for working. There is probably room for both, for different things if funds allow.

      Reply
  2. Pankhudhi

    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.

    Reply
    • Hoi Marin en Dikky!We zullen zelf dadelijk ook wat fo#27t8o1&;s gaan plaatsen!We genieten volop, maar het is ook spannend. FF wennen!Tot snel weer!

      Reply
    • oh yeah! it loooooks sooo goood. I love kawasaki for their &quru;oeplicas&qtot; :) w650,w800, zephyr. Got myself a zeph 750 and I'm looking now for some exhaust idea. ok enough of writingbtw bubble visor = super ok, mega cool blogkeep it up

      Reply
    • Thanks. This is something that I&8;217#ll always struggle with, but I’m managing it pretty well right now. I know that I’m far from alone in feeling this (several of my friends suffer from similar feelings); I mainly wanted to put this post out there to say the same thing to other people who might be going through what I was going through a few months ago.

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

    Reply
    • Roberta

      And thank you for the great book! I have also been enjoying your blog, and it gives me hope that buying local and thinking about where our food (and all of our consumer prduscto) come from will be something we all pay more attention to in the future.

      Reply
  4. 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.

    Reply
    • We take our long haired cat to the vet for a haircut every spring after we are sure the warmer months have started & the hair grows back to full length by the middle of autumn so he always has a full coat for wi.ternYou should get your cat a flea collar or flea medicine to get rid of the fleas

      Reply
    • Aw, this became an really nice post. In thought I would like to devote writing such as this moreover – taking time and actual effort to make a quite great arcÂlteâ€i¦ but exactly what do I say… I procrastinate alot and by no indicates locate a approach to get something completed.

      Reply

Leave a Reply