- What is the base contract?
The parent contract (that is inherited by child contract)
- Which functions are available for derived contracts?
internal & public functions
- What is hierarchical inheritance?
single contract act as a base contract for multiple derived (child) contracts
I would also like to share some typo mistake of the code of this blog post regarding abstract contract vs interfaces. The example of the interfaces part seems to be incorrect (typo due to copy & paste I guess).
Abstract Contract Example
contract abstractHelloWorld {
function GetValue() public view returns (uint);
function SetValue(uint _value) public;
function AddNumber(uint _value) public returns (uint) {
return 10;
}
}
contract HelloWorld is abstractHelloWorld{
uint private simpleInteger;
function GetValue() public view returns (uint) {
return simpleInteger;
}
function SetValue(uint _value) public {
simpleInteger = _value;
}
function AddNumber(uint _value) public returns (uint ){
return simpleInteger = _value;
}
}
Interfaces Example
contract InterfaceHelloWorld {
function GetValue() public view returns (uint);
function SetValue(uint _value) public;
}
contract HelloWorld is InterfaceHelloWorld{
uint private simpleInteger;
function GetValue() public view returns (uint) {
return simpleInteger;
}
function SetValue(uint _value) public {
simpleInteger = _value;
}
}