Inheritance

This Atom is Under Construction

Inheritance is a mechanism for reusing the behaviour of a base class in a derived class with some modifications.

Objects store data in properties and perform actions via member functions. Each object occupies a unique place in storage so one object’s properties can have different values from every other object. An object also belongs to a category called a class, which determines the form or template for its objects: the properties and functions. Thus, all objects look like the class that created them (via its constructor).

Creating and debugging a class can require a lot of work. What if you want to make a class that’s like an existing class, but with some variations? It seems a pity to build a new class from scratch. Object-oriented languages provide a mechanism for reuse called inheritance.

Inheritance follows the concept of biological inheritance. You say, “I want to make a new class from an existing class, but with some additions and modifications.”

End of sample. See AtomicKotlin.com for full early-access book.



Previous          Next

©2018 Mindview LLC. All Rights Reserved.