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 are destructors?
Differentiate between late binding and early binding.
Explain the difference between class and struct in c++?
Consider the following C++ program
Explain binary search.
What is the limitation of cin while taking input for character array?
Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)
Define namespace.
What is an object in c++?
What are c++ tokens?
What is the problem with multiple inheritance?
What is the best c++ book?
Is this job good for future? can do this job post grduate student?
What are the defining traits of an object-oriented language?
What is stream and its types in c++?