ambiguity regulation of multiple inheritance with example.
Answer Posted / sahadev tarei
if A class have one function fun().B is a another class
derived from A and it has also one function fun().C is
another function derived from B and also It has one
function Fun().for the role of inheritance C contains 3 fun
().
1. Fun()---inherited from A
2. fun()--- inherited from B
3. fun() -- own C class function
When a user create an object of C and invock to A class Fun
().It wont. tais ambiguti
Example:-
class A
{
public:
void fun()
{
cout<<"A"
}
}
class B:public A
{
public:
void fun()
{
cout<<"B"
}
}
class C:public B
{
public:
void fun()
{
cout<<"C"
}
}
int main()
{
C obj;
obj.fun()---- acess C class function
obj.A::fun();---invock A class function
obj.B::fun();---invocks B class function
return 0;
}
output
C A B
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
What is the difference between encapsulation and polymorphism?
What is the importance of oop?
write string class as your own class in java without using any built-in function
write a program to find 2^n+1 ?
Plese get me a perfect C++ program for railway/airway reservation with all details.
What is the fundamental idea of oop?
What is object and example?
What is pure oop?
Why do we use inheritance?
Why do we use class?
Please send ford technologies placement paper 2 my mail id
Which type does string inherit from?
What is abstraction and encapsulation?
Why do we use polymorphism in oops?
What is the difference between static polymorphism and dynamic polymorphism?