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
Is multimap sorted c++?
Is it possible to have a recursive inline function in c++?
What is ostream in c++?
what you know about c++?
What is c++ iterator?
What is a literal in c++?
Explain what are the sizes and ranges of the basic c++ data types?
Search for: what is pair in c++?
When must you use a pointer rather than a reference?
Is c++ high level programming language?
What is c++ and its features?
What is a stack c++?
How can you link a c program with a c function?
When is the destructor called?
What is a manipulative person?