26.8.15

Illustrate multiple inheritance

Write a c++ program :

b) to illustrate multiple inheritance

#include<iostream.h>

#include<conio.h> class m

{

protected : int m; public:

void getm()

{

cout<<"\nEnter the value for m : "; cin>>m;

}

}; class n

{

protected : int n; public:
void getn()

{

cout<<"\nEnter the value for n : "; cin>>n;
}

};

class p : public m , public n

{ public:

void display()

{

cout<<"\nM="<<m;

cout<<"\nN="<<n;

cout<<"\nM*N="<<m*n;

}


};

int main()

{

clrscr();

p p1;

p1.getm();

p1.getn();

p1.display();

getch();

return 0;

}


************************************OUTPUT******************************

Enter the value for m : 12

Enter the value for n : 10

M=12

N=10

M*N=120

No comments:

Post a Comment

Comment Here