-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathInheritance.sol
More file actions
45 lines (35 loc) · 784 Bytes
/
Inheritance.sol
File metadata and controls
45 lines (35 loc) · 784 Bytes
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
43
44
45
pragma solidity >=0.4.25 <0.6.0;
//Parent contract
contract Parent {
uint internal value;
function SetValue(uint input) public {
value = input;
}
}
//Inherit parent contract
contract Child is Parent {
bool private isValid;
function GetValue() public view returns (uint) {
return value;
}
}
//Parent contract 2
contract Parent2 {
bool internal eligible;
}
//Multiple inheritance
contract Derived is Parent2, Parent {
bool private isValid;
function GetValue() public view returns (uint) {
return value;
}
}
contract Client {
Child child = new Child();
function callInheritedFunctions() public returns (uint) {
//Invoke Parent contract
child.SetValue(10);
//Invoke Child contract
return child.GetValue();
}
}