Google

Difference between a Virtual class and an Abstract class in C++

Written on:May 28, 2013
Comments are closed




Difference between a Virtual class and an Abstract class in C++

Virtual Class: A virtual class is one that has been qualified as virtual in the inheritance definition.  When a derived class inherits from more than one base class, then it can inherits the members of a base class from multiple inheritance paths. If the base class is defined as virtual, only one copy of the members of the base class is inherited by the derived class irrespective of the fact that it can be inherited from a number of inheritance paths.

 

Abstract Class: An abstract class is one, which is never instantiated.  The objects of an abstract base class are never created.  A base class that contains pure virtual functions is an abstract base class.  A pure virtual function is a virtual function that has no implementation in its class.  Thus an abstract class provides a base upon which to build other classes.  It is designed only to act as a base class for other classes and it is not used to create objects.  Thus an abstract base class provides some transit to the derived classes and is never initiated.

Sorry, the comment form is closed at this time.