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

Program to check whether a word is in all capital letters

1 Answers  


Given two strings like x=?hello? and y=?open?, remove any character from string x which is also used in string y, thus making the result x=?hll?.

13 Answers   IBM,


if u write a class do u write Assignment operator and copy constructor

1 Answers   Siemens,


What is extreme programming?

2 Answers  


What is polymorphism explain its types?

0 Answers  






diff between Virtual mathod and abstract method?

1 Answers  


what is code for call by value and call by reference?

1 Answers  


Can we call a base class method without creating instance?

6 Answers  


You have one base class virtual function how will call that function from derived class?

4 Answers  


How is class defined?

0 Answers  


create a c++ program that will accepts 9 inputs using 3 by 3 array.

1 Answers  


What is polymorphism what are the different types of polymorphism?

0 Answers  


Categories