CH13 Inheritance

All inheritance does is LITERALLY copy-paste the code of the parent contract into the child contract. That's it!

Basic Syntax of Inheritance

Solidity supports multiple inheritance. Contracts can inherit other contract by using the is keyword.

Function that is going to be overridden by a child contract must be declared as virtual.

Function that is going to override a parent function must use the keyword override.

contract Parent {
		//Function that is going to be overridden by a child contract must be declared as virtual
    function sayHello() public pure virtual returns (string memory) {
        return "Hello from Parent";
    }
}

contract Child is Parent {
		//Function that is going to override a parent function must use the keyword override.
    function sayHello() public pure override returns (string memory) {
        return "Hello from Child";
    }
}

CH14 Abstract and Interfaces

Abstract Contracts

Abstract contracts in Solidity have the following characteristics: