Answer Posted / raj randhawa
Suppose you have two derived classes B and C that have a
common base class A, and you also have another class D that
inherits from B and C. You can declare the base class A as
virtual to ensure that B and C share the same subobject of
A.
In the following example, an object of class D has two
distinct subobjects of class L, one through class B1 and
another through class B2. You can use the keyword virtual
in front of the base class specifiers in the base lists of
classes B1 and B2 to indicate that only one subobject of
type L, shared by class B1 and class B2, exists.
For example:
class L { /* ... */ }; // indirect base class
class B1 : virtual public L { /* ... */ };
class B2 : virtual public L { /* ... */ };
class D : public B1, public B2 { /* ... */ }; // valid
Using the keyword virtual in this example ensures that an
object of class D inherits only one subobject of class L.
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
Is atoi safe?
What is the correct syntax for inheritance a) class aclass : public superclass b) class aclass inherit superclass c) class aclass <-superclass
What is the difference between the functions memmove() and memcpy()?
What are c++ variables?
given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy
What is debug class?what is trace class? What differences are between them? With examples.
What is a container class?
Why should a c++ programmer be interested in stl?
Please send ford technologies placement paper 2 my mail id
program explaining feautures of c++
Can a constructor be private?
Write about a nested class and mention its use?
What are the various compound assignment operators in c++?
How is new() different from malloc()?
Why would you use pointers in c++?