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 are objects in oop?
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
How does polymorphism work?
How do you define a class in oop?
What is abstraction in oop with example?
Why is polymorphism important in oop?
Why is oop better than procedural?
Are polymorphisms mutations?
What is debug class?what is trace class? What differences are between them? With examples.
What is overriding in oops?
What is oops and its features?
What is a superclass in oop?
is there any choice in opting subjects like 4 out of 7
What is inheritance and how many types of inheritance?
Why is abstraction needed?