Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We'll leave a more complete C++ introduction to the pros, but there's one aspect of the language that we found confusing at first, but turned out to be incredibly useful: **virtual methods.**

When you create a new class that's a child of an existing class, it inherits all of the public methods from its parent. This leads to two common situations:

...

Just to confuse you a bit more, you have to keep in mind that virtual methods differ from **pure virtual** methods, which are defined by setting a virtual method equal to zero, e.g.: `virtual void parentMethod() = 0;`. If a method is pure virtual, it means that the class it belongs to _can never exist_. Classes with pure virtual methods can only act as parent classes, and all of their children must define some implementation of the pure virtual methods, otherwise they will themselves be virtual.