WAP to find the ambiguities in Multiple Inheritance? How
are they
resolved.(Virtual Functions)




WAP to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtua..

Answer / 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

More OOPS Interview Questions

What is pure oop?

0 Answers  


Can private class be inherited?

0 Answers  


What is a null tree?

0 Answers  


What is a template?

7 Answers  


There are 2 classes defined as below public class A { class B b; } public class B { class A a; } compiler gives error. How to fix it?

3 Answers   Microsoft,






How to create a comment page in C #??

2 Answers  


Polymorphism with an example?

8 Answers   Accenture, emc2,


what is the difference between containership and inheritence?

1 Answers  


what is the usage of clas templates

5 Answers  


Why is there no multiple inheritance?

0 Answers  


What is the default size allocated for array in the statement if size not specified " int a[] "

4 Answers   CTS,


Why do we use class in oops?

0 Answers  


Categories