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
What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0
What is the difference between *p++ and (*p)++ ?
Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?
Explain the difference between c++ and java.
What is the protected keyword used for?
Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.
write a corrected statement so that the instruction will work properly. if (4 < x < 11) y = 2 * x;
When does a name clash occur in c++?
What is ios flag in c++?
On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?
Am pass the 10000 records to target in target I will take commit interval 15000 when I was stop the work flow what will happened
What new()is different from malloc()?
What is the last index number in an array of 100 characters a) 100 b) 99 c) 101
Should the this pointer can be used in the constructor?
What is the main purpose of overloading operators?