what is a virtual class?

Answers were Sorted based on User's Feedback

what is a virtual class?..

Answer / raj

In multiple inheritance when a class D is derived by two
base classes B and C and both base class is also inherite
by same class A then then class D will get duplicate copy
of uppper most base class A.In this case class A will
declare as virtual class

Is This Answer Correct ?    41 Yes 5 No

what is a virtual class?..

Answer / kar4you

Suppose you have two derived classes B and C that have a
common base class A, and you also have another class D that
inherits from B and C. You can declare the base class A as
virtual to ensure that B and C share the same subobject of

In the following example, an object of class D has two
distinct subobjects of class L, one through class B1 and
another through class B2. You can use the keyword virtual
in front of the base class specifiers in the base lists of
classes B1 and B2 to indicate that only one subobject of
type L, shared by class B1 and class B2, exists.

class L { /* ... */ }; // indirect base class
class B1 : virtual public L { /* ... */ };
class B2 : virtual public L { /* ... */ };
class D : public B1, public B2 { /* ... */ }; // valid

Is This Answer Correct ?    6 Yes 0 No

what is a virtual class?..

Answer / ramakrishna

It is used to avoid the ambiguity problem in c++ (multiple
when sub class inherits same members from 2 base classes.
compiler dont know which variable has assigned the value.

If u declare the class as virtual only one time is
inherited in its derived class.A copy will never get
concept of virtual methods is different purpose.
like how we have abstract key word in java,we can acheive
method abstraction using virtual keyword before a method.

please select no if u really know this answer is wrong.
people with out having knowlede saying simple know hurts
the technical world.
Ramakrishna Yechuri
sr corporate Trainer

Is This Answer Correct ?    6 Yes 2 No

what is a virtual class?..

Answer / ritesh parkhi

Virtual class in a part or used to implement Runtime
polymorphism.Through it dynamically we can access a class or
method of that class.With use of Pointer to base class we
can implememt it.We try to access object of any class
without regarding their class.We are passing object address
in this base class pointer to access a particulat method of
a class at runtime.

Is This Answer Correct ?    8 Yes 5 No

what is a virtual class?..

Answer / roll no 009

it is nuthin but a class which consists of 72 students wid
a borin h.o.d who thinks all are listening but you know the
truth i.e no 1 is 4 sure..such a type of class is called

Is This Answer Correct ?    4 Yes 18 No

Post New Answer

More OOPS Interview Questions

design class for linked list and include constructor,destructor,insert option. node of form struct node { int data; struct node &ptr; }

0 Answers  

Have you ever used threads?

3 Answers   Adobe, IBM,

can inline function declare in private part of class?

1 Answers  

What is differance between Abstract and Interface

3 Answers  

Base class has two public data members. How can i derive a new class with one datamember as public and another data member as private?.

2 Answers  

write a program that takes input in digits and display the result in words from 1 to 1000

0 Answers   Wipro,

The company is a fake company asking for money of RS10000 while training and not offering a job after training. My humble request to you people not to attend Astersys interview

1 Answers   Astersys,

what is opps?why it is use in programming language?

2 Answers   Wipro,

diff between Abstract class Interfaces?

4 Answers  

What are the advantanges of modularity

2 Answers  

What is abstrac class?where is it use?

2 Answers  

what is overloading

3 Answers