What Is Base Class?
In object-oriented design, a class type defined as containing all entities in common is called a "base class".
- 1. Base class, parent class, super class refers to the inherited class, derived class, and subclass refers to the class inherited from the base class.
- 2. Used in C ++: The colon indicates inheritance, such as class A: public B; indicates that the derived class A inherits from the base class B
- 3. Derived class contains all members of the base class, and also includes its own unique members. Derived and derived objects can access members in the base class just as they access their own members. But the derived class still cannot access the private members in the base class.
- 4. In C ++ derived classes can inherit from multiple base classes at the same time,
- The inheritance process creates a new derived class consisting of members of the base class plus any new members added by the derived class
- In the figure, a graphical representation of the components of CollectibleString and CollectibleSortable is shown. However, the base class Collectible is located in CollectibleSortable via CollectibleSortableString path and CollectibleString path. To eliminate this redundancy, such classes can be declared as a virtual base class when inheriting.