Class Inheritance: What is it?

A component of object-oriented programming, inheritance happens when a new object takes on properties of objects that already exist.

What’s the benefit of this?

Consider when creating items for an RPG. You will have many items:

Crates, pots, weapons, consumables, amulets, gems, spells, coin and so on.

We could start with a custom class named Item. Each item will have a name, item id, and icon.

Now, let’s create another custom class named Weapons and allow it to inherit from the Item class.

Learn More