Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is a virtual base class?

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


Please Help Members By Posting Answers For Below Questions

What are multiple inheritances (virtual inheritance)?

1062


Can I learn c++ in a week?

1074


What do you mean by persistent and non persistent objects?

1435


Mention the purpose of istream class?

1115


What do c++ programmers do?

1060


Can you write a function similar to printf()?

1130


How does com provide language transparency?

1010


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?

981


What will the line of code below print out and why?

742


Can constructor be private in c++?

1045


Explain selection sorting. Also write an example.

1050


What do you mean by function overriding & function overloading in c++?

1190


How do you show the declaration of a virtual constructor?

942


Write about the use of the virtual destructor?

1009


What does the linker do?

1043