Contract polymorphism
Contract polymorphism refers to using multiple contract instances interchangeably when the contracts are related to each other by way of inheritance. Contract polymorphism helps in invoking derived contract functions using a base contract instance.
Let's understand this concept with the help of code listing shown next.
A parent contract contains two functions, SetInteger and GetInteger. A child contract inherits from a parent contract and provides its own implementation of GetInteger. The child contract can be created using the ChildContract variable data type and it can also be created using the parent contract data type. Polymorphism allows the use of any contract in a parent-child relationship with the base type contract ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access