What Does Base Class Mean?
A base class is a class, in an object-oriented programming language, from which other classes are derived. It facilitates the creation of other classes that can reuse the code implicitly inherited from the base class (except constructors and destructors). A programmer can extend base class functionality by adding or overriding members relevant to the derived class.
A base class may also be called parent class or superclass.
Techopedia Explains Base Class
A class derived from a base class inherits both data and behavior. For example, “vehicle” can be a base class from which “car” and “bus” are derived. Cars and buses are both vehicles, but each represents its own specialization of the vehicle base class.
A base class has the following properties:
- Base classes are automatically instantiated before derived classes.
- The derived class can communicate to the base class during instantiation by calling the base class constructor with a matching parameter list.
- Base class members can be accessed from the derived class through an explicit cast.
- If abstract methods are defined in a base class, then this class is considered to be an abstract class and the non-abstract derived class should override these methods.
- Abstract base classes are created using the “abstract” keyword in its declaration and are used to prevent direct initiation using the “new” keyword.