-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInheritance.sol
43 lines (31 loc) · 876 Bytes
/
Inheritance.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
pragma solidity >=0.4.0 <0.7.0;
import './SuperContract.sol';
/**
* @title Super and SubContracts
* @author Blockchain Trainer (@blockchaintrainer)
*
* Demonstrate inheritance in solidity
*/
/*
contract SuperContract {
//this field is inherited
uint public inheritThis;
//this method is also inherited
function superMethod() public view returns (string memory) {
return "this is from inherited method";
}
}*/
contract Inheritance is SuperContract {
function set(uint x) public {
inheritThis = x;
}
/*view method it does't change the contract state -
only reads it - this is indicated by the view modifier
*/
function get() public view returns (uint) {
return inheritThis;
}
function getSuper() public view returns (string memory) {
return superMethod();
}
}