December 2018
Beginner to intermediate
564 pages
17h 34m
English
Solidity supports multiple inheritance by copying code including polymorphism. Even if a contract inherits from multiple other contracts, only a single contract is created on the blockchain; the code from the parent contracts is always copied into the final contract.
Here is an example to demonstrate inheritance:
contract sample1 { function a(){} function b(){} } //sample2 inherits sample1 contract sample2 is sample1 { function b(){} } contract sample3 { function sample3(int b) { } } //sample4 inherits from sample1 and sample2 //Note that sample1 is also parent of sample2, yet there is only a single instance of sample1 contract sample4 is sample1, sample2 { function a(){} function c(){ //this executes the "a" method of ...Read now
Unlock full access