C++ Chapter 15: Inheritance Basics

  1. Inheritance is the process by which a new class-known as a derived class- is created from another class, called the base class.
  2. A derived class automatically has all the member variables and functions that the base class has and can have additional member functions and/or additional member variables.
  3. A base class is also a parent class.
  4. A derived class is also a child class.
  5. The derived class inherits the member variables and member functions.
  6. The definition of an inherited member function can be changed in the definition of a derived class so that it has a meaning in the derived class that is different from what it is in the base class. This is called redefining the inherited member function.
  7. A class that is a parent of a parent of a parent of another class is often called an ancestor class.
  8. A class is an ancestor of another class that is a class of another class is often called a decendent of that class.
  9. A constructor in a base class is not inherited in the derived class, but you can invoke a constructor of the base class with the definition of a derived class constructor.
  10. A constructor for a derived class uses a constructor from the base class in a special way. A constructor for the base class intializes all the data inherited from the base class. Thus, a constructor for a derived class begins with an invocation of a constructor for the base class.
  11. You should always include an invocation of one of the base class constructors in the initialization section of a derived class constructor.
  12. A derived class does not inherit the constructors of its base class. However, when defining a constructor for the derived class, you can and should include a call to a constructor of the base class. If you do not include a call to a constructor of the base class, then the default constructor of the base class will automatically be called when the derived class constructor is called.
  13. An accessor function is a function that allows you to access member variables of a class.
  14. A mutator function is one that allows you to change member variables of a class.
  15. A member variable (or member function) that is private in a base class is not directly accessible outside of the interface and implementation of the base class, not even in a member function definition for a derived class.
  16. A private variable can be accessed indirectly via an accessor or mutator member function.
  17. If you use the qualifier protected, rather than private or public, before a member variable or member function of a class, then for any class or function other than a derived class, the effect is the same as if the member variable were labeled private; however, in a derived class the variable can be accessed by name.
  18. If a member is marked as protected in a base class, then it can be accessed by name in the definitions of all descendent classes, not just in those classes directly derived from the base class.
  19. Inheritance provides a tool for code reuse by deriving one class from another by adding features to the derived class.
  20. Derived class objects inherit all the members of the base class and may add members.
  21. When a member function is redefined in a derived class you must list its function declaration in the class definition even though the function declaration is the same as in the base class.
Author
senator77
ID
147052
Card Set
C++ Chapter 15: Inheritance Basics
Description
C++ Chapter 15: Inheritance Basics
Updated