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 is inheritance in oop?
What are guid? Why does com need guids?
Differentiate between C and C++.
How many times will this loop execute? Explain your answer.
What are two types of polymorphism?
Which one between if-else and switch is more efficient?
What is a catch statement?
Is c++ used anymore?
What is the most useful programming language?
What is an inline function in c++?
What is a block in c++?
Why c++ does not have finally?
Why do we use structure in c++?
Explain the differences between private, public and protected and give examples.
what is oops and list its features in c++?