WAP to find the ambiguities in Multiple Inheritance? How
are they
resolved.(Virtual Functions)
Answer Posted / niraj verma
Multiple Inheritance:-
A class can inherit the attributes of two or more classes.
This is know as multiple inheritance. Multiple inheritance
allows us to combine the features of several existing
classes as a starting point for designing new classes. It is
like a child inheriting the physical features of one parent
and the intelligence of onother.
In Multiple
Inheritance the derived class inherit the properly of more
than one base class.
Example:-
# include<iosteam.h>
# include<conio.h>
Class A
{
Protected:
Int x;
Public:
Void getdata ( )
{
Cout<<”\n Enter any
number”;
Cin>>x;
}
};
Class B
Protected:
Int y;
Public:
Void getadta2 ( )
{
Cout<<”\n Enter any number”;
Cin>>y;
}
};
Class c: public A, public B
{
Private:
M, z;
Public:
Void getdata3 ( )
{
Cout<<”\n Enter
any number”;
Cin>>m;
}
Void calculate ( )
{
Z = x*y+m;
}
Void display (
)
{
Cout <<
“\n Result =”<<z;
}
};
Void main ( )
{
C obj;
Obj. getdata1 ( );
Obj. getdata2 ( );
Obj. getdata3 ( );
Obj. calculate ( );
Obj. display ( );
Getch ( );
}
Is This Answer Correct ? | 5 Yes | 2 No |
Post New Answer View All Answers
What is oops and why we use oops?
Who invented oop?
What is the difference between encapsulation and polymorphism?
What is inheritance and how many types of inheritance?
#include
Get me an image implementation program.
What are two types of polymorphism?
What is destructor in oop?
What is polymorphism programming?
How to call a non virtual function in the derived class by using base class pointer
What is the real time example of encapsulation?
What do you mean by abstraction?
What is class encapsulation?
How to use CMutex, CSemaphore in VC++ MFC
What is oops and its features?