root

Trivial example illustrating basic OOP inheritance.

We have 3 classes:

  • Ass, implementing method scratch()

  • Balls, inherited from Ass, additionally implementing method touch()

  • Scratcher, implementing method scrape() which works with Ass.scratch()

The core idea of inheritance is that the child class (Balls) inherits all the methods of parent class (Ass), so external users (Scratcher) are able to treat the child class as if it was parent class without any code changes.