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

What is ambiguity in c++

4 Answers   Accenture, Mphasis,


In c++ there is only virtual destructors, no constructors. Why?

4 Answers   IBM, Polaris,


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<<k; } //please comment on the output

0 Answers  


In which cases you use override and new base?

2 Answers  


can you give real time example for polymarphism

5 Answers   TCS,


hi all..i want to know oops concepts clearly can any1 explain??

0 Answers   Eureka Forbes,


Why do we use encapsulation in oops?

0 Answers  


What is property in oops?

0 Answers  


what is the usage of clas templates

5 Answers  


why the argument is passed by reference to a copy constructor?example?

2 Answers  


Write a program to demonstrate the use of 'Composition' in C++

2 Answers  


who is the founder of c++?

15 Answers   Hexaware, ONGC,


Categories