ambiguity regulation of multiple inheritance with example.



ambiguity regulation of multiple inheritance with example...

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

More OOPS Interview Questions

How do you define social class?

0 Answers  


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

0 Answers  


WHAT IS THE ACTUAL DEFINATION OF OBJECT AND THE CLASS IN ONE SINGLE LINE WHICH THE INTERVIEWER WANT TO LISTEN.

11 Answers  


What is coupling in oops?

0 Answers  


INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

0 Answers  


What is the difference between const int *ptr and int const *ptr???

2 Answers  


Why do we use polymorphism in oops?

0 Answers  


What is super in oop?

0 Answers  


what is the basic concept of inheritance?

9 Answers  


Describe what an Interface is and how it?s different from a Class.

7 Answers   Spinsys,


What is the difference between pass by value,pass by pointer,pass by reference in the catch block in the exception handling in c++

1 Answers   TCS,


Can we have a private constructor ?

12 Answers   HSBC, Ness Technologies, TCS, Wipro,


Categories