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 / ragib nasir ahmed

A virtual base class is one in which only one copy of the
base class is inherited to the derived class.
Let us consider the classes A,B,C,D
class A
{
int a;
public:
void geta(void)
{
a=10;
}
};
class B: public virtual A
{
int b;
public:
void getb(void)
{
b=20;
}
};
class C:virtual public A
{
int c;
public:
void getc(void)
{
c=30;
}
};
class D:public B,public C
{
public:
void display(void)
{
cout<<a<<b<<c<<d;
}
};

Is This Answer Correct ?    25 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the benefits of operator overloading?

1221


What is the difference between a declaration and a definition?

1124


What is insertion sorting?

1122


How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?

1042


What is encapsulation in oops?

1020


Describe protected access specifiers?

1239


What is the difference between Stack and Queue in C++?

1080


What is difference between abstraction and encapsulation?

1087


write string class as your own class in java without using any built-in function

2508


What is a volatile variable in c++?

1478


Can we call a virtual function from a constructor?

1325


What is the use of namespace std in C++?

1074


Is atoi safe?

1059


What is the role of static keyword for a class member variable?

1075


What does iomanip mean in c++?

1209