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 the advantage of oop over procedural language?

634


What is interface in oop?

670


What is class and example?

577


What is polymorphism explain?

702


What is polymorphism used for?

583






what is graphics

2022


Is enum a class?

613


explain sub-type and sub class? atleast u have differ it into 4 points?

1844


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

709


Why is there no multiple inheritance?

579


What are the features of oop?

645


Why is polymorphism used?

592


How to hide the base class functionality in Inheritance?

652


What is encapsulation c#?

613


What do you mean by Encapsulation?

651