Solidity Inheritance: Virtual & Override Keywords Explained

Added:

Inheritance Basics
Multi-Level Override

Inheritance Basics

0:00
Playing Section
  • 1

    Introduces inheritance to eliminate code duplication between contracts.

  • 2

    Explains virtual and override keywords for customizing parent functions.

  • 3

    Demonstrates child contract accessing undeclared inherited functions.

Basic understanding of Object-Oriented Programming (OOP) principles, specifically the concept of class inheritance.
Familiarity with basic Solidity syntax, including contract definition, state variables, and functions.
Understanding how basic contract inheritance is declared in Solidity using the 'is' keyword.
Knowledge of Solidity function visibility specifiers (public, external, internal, and private) and how they restrict access.
How to define and implement Abstract Contracts and Interfaces in Solidity, where functions are implicitly virtual.
Understanding Multiple Inheritance in Solidity and how the compiler resolves function calls using C3 Linearization.
Utilizing the 'super' keyword to call parent contract functions within overridden methods.
Advanced smart contract design patterns (such as Upgradeable Proxies and the Factory Pattern) that rely heavily on polymorphism.
16K views302likes3:59@smartcontractprogrammerOriginal Release: 2021-11-25

In Solidity, inheritance allows child contracts to reuse parent contract code while customizing specific functions. To enable function customization, parent contracts must declare functions as 'virtual', and child contracts must use the 'override' keyword when redefining those functions. Functions not overridden in the child contract remain accessible from the parent, enabling multiple levels of inheritance where each level can override functions from its parent.