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
Why do we need polymorphism in c#?
How do you define social class?
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
What are the advantages of polymorphism?
How do you answer polymorphism?
What is oops in simple words?
What is the oops and benefits of oops programming?
when to use 'mutable' keyword and when to use 'const cast' in c++
write string class as your own class in java without using any built-in function
What is the importance of oop?
There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.
Which is not an object oriented programming language?
What is difference between data abstraction and encapsulation?
hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.
Why do we use polymorphism in oops?