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


Please Help Members By Posting Answers For Below Questions

What is difference between polymorphism and inheritance?

617


Can bst contain duplicates?

670


What is and I oop mean?

622


What are the benefits of oop?

607


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

1621






Which language is not a true object oriented programming language?

643


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.

1789


Why interface is used?

554


Can we have inheritance without polymorphism?

617


what is the sylabus for priliminaries?

1691


What is abstraction in oop with example?

646


Why do pointers exist?

661


what is the 3 types of system development life cycle

2435


How do you use inheritance in unity?

590


Why is polymorphism used?

586