Class Inheritance

Here we have a look at class inheritance in C++. The principle of class inheritance is the same as in Java Everything else is different.

  1. The syntax for declaring an inheritance is a bit different.
  2. There is no super, and there are different ways to refer to the base class.
  3. Polymorphism is handled quite differently. (Yes, I will tell you what I'm talking about at some point.)
  4. There is a protected: keyword, which is a bit more restrictive than the one in Java.
  5. C++ allows multiple inhertance (inherit from multiple base classes).
    1. We probably won't talk about it much.
    2. Most reasonable use is to simulate something similar to Java's interfaces, since C++ does not have those. Many C++ coding shops have rules limiting multiple inheritance to this use.
Textbook: Chapter 15