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 is the advantage of oop over procedural language?
What is interface in oop?
What is class and example?
What is polymorphism explain?
What is polymorphism used for?
what is graphics
Is enum a class?
explain sub-type and sub class? atleast u have differ it into 4 points?
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.
Why is there no multiple inheritance?
What are the features of oop?
Why is polymorphism used?
How to hide the base class functionality in Inheritance?
What is encapsulation c#?
What do you mean by Encapsulation?