Single inheritance

Single inheritance helps in inheriting the variables, functions, modifiers, and events of base contracts into the derived class. Take a look at the following diagram:

The next code snippets help to explain single inheritance. You will observe that there are two contracts, ParentContract and ChildContract. The ChildContract contract inherits from ParentContract. ChildContract will inherit all public and internal variables and functions. Anybody using ChildContract, as seen in the client contract, can invoke both GetInteger and SetInteger functions as if they were defined in ChildContract, as shown in the following screenshot: ...

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.