Answer Posted / rama
The duplication of inherited members due to multiple paths can be avoided by making the common base class(ancestor class) as virtual base class..
FOR EXAMPLE
class A //grandparent
{
...
...
};
class B1:virtual public A //parent1
{
...
...
};
class B2:public virtual A //parent2
{
...
...
};
class C :public B1,public B2
{
... //only one copy of A
... //will be inherited
};
When a class is made a virtual base class, it take necessary care to see that only one copy of that class is inherited, regardless of how many inheritance paths exits between the virtual base class and a derived class.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How many characters are recognized by ANSI C++?
which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
What is object in c++ wikipedia?
What is rvalue?
What is a sequence in c++?
Is there structure in c++?
What is an orthogonal base class in c++?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
Is it legal in c++ to overload operator++ so that it decrements a value in your class?
What does flush do?
what are the events occur in intr activated on interrupt vector table
Do you know what is overriding?
What is the full form of india?
Why do we need runtime polymorphism in c++?
Explain bubble sorting.