Class Inheritance

suggest change

Introduction

Any object-oriented programming language has some form of class inheritance. For example:

Imagine you had to program a bunch of fruit: Apples, Oranges and Pears. They all differ in size, shape and color, that’s why we have different classes.

But let’s say their differences don’t matter for a second and you just want a Fruit, no matter which exactly? What return type would getFruit() have?

The answer is class Fruit. We create a new class and make all fruits inherit from it!

Syntax

Parameters

Parameter Details
Base Class Class that is inherited from
Derived Class Class that inherits from the base class
Init Arguments Arguments passed to the constructor of the base class
Function Definition Function in the derived class that replaces the one in the base class
DC-Object “Derived Class-Object”: an object whose type is the derived class

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents