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 difference between polymorphism and inheritance?
Can bst contain duplicates?
What is and I oop mean?
What are the benefits of oop?
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer
Which language is not a true object oriented programming language?
Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.
Why interface is used?
Can we have inheritance without polymorphism?
what is the sylabus for priliminaries?
What is abstraction in oop with example?
Why do pointers exist?
what is the 3 types of system development life cycle
How do you use inheritance in unity?
Why is polymorphism used?