- Inherit contracts using the is keyword. The parent contract has to be imported or copied to the same file before inheriting:
contract A { ...}contract B is A { ...}
- When a contract inherits from multiple contracts, only a single contract is created in the blockchain. The other code from all the base contracts is copied into the created contract.
- In inheritance, the final function will be invoked while calling it by name. Call the functions in the parent contract by explicitly specifying their names:
pragma solidity ^0.4.23;contract A { uint public value; function changeValue() public { value = 1; }}contract B is A { function changeValue() public { value = 2; }}
- Access the functions from the base contract using the ...