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
What do you mean by volatile and mutable keywords used in c++?
What is an undefined behavior and sequence points
What are the three forms of cin.get() and what are their differences?
Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---
What is for loop and its syntax?
What sorting algorithm does c++ use?
Why do we need c++?
What are the two types of comments?
Why should we use null or zero in a program?
Can constructor be private in c++?
What are the costs and benefits of using exceptions?
What is difference between data abstraction and encapsulation?
How does an stl file work?
Is c++ a difficult language?
What is the difference between set and map in c++?