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
Which bitwise operator is used to check whether a particular bit is on or off?
Explain what are the sizes and ranges of the basic c++ data types?
What is the c++ code?
What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0
Why is polymorphism used?
What is a class in oop?
What does new do in c++?
How would you use the functions sin(), pow(), sqrt()?
How the endl and setw manipulator works?
What are the differences between java and c++?
Can we declare a base-class destructor as virtual?
What is polymorphism explain its types?
just right the logic of it 1--> If few people are electing then every time ur candidate should win 2--> arrange books in box, if box carry weight == books weight then take another box..... find the no of box required.
Can main method override?
What is an advantage of polymorphism?