Answer Posted / atul jawale
Virtual base class is a base class acts as an indirect base
for more than one without duplication of its data members.
A single copy of its data members is shared by all the base
classes that use it as a virtual base.
For example:
A
/ \
B C
\ /
D
class A { /* ... */ }; // indirect base class
class B : virtual public A { /* ... */ };
class C : virtual public A { /* ... */ };
class D : public B, public C { /* ... */ }; // valid
Using the keyword virtual in this example ensures that an
object of class D inherits only one subobject of class A.
| Is This Answer Correct ? | 75 Yes | 7 No |
Post New Answer View All Answers
What are multiple inheritances (virtual inheritance)?
Can I learn c++ in a week?
What do you mean by persistent and non persistent objects?
Mention the purpose of istream class?
What do c++ programmers do?
Can you write a function similar to printf()?
How does com provide language transparency?
How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?
What will the line of code below print out and why?
Can constructor be private in c++?
Explain selection sorting. Also write an example.
What do you mean by function overriding & function overloading in c++?
How do you show the declaration of a virtual constructor?
Write about the use of the virtual destructor?
What does the linker do?