-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathline23.sol
More file actions
43 lines (32 loc) · 845 Bytes
/
line23.sol
File metadata and controls
43 lines (32 loc) · 845 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
// SPDX-License-Identifier: MIT
//SPDX-License-Idetifier: Unlicensed
// virtual and override
// virtual functions are functions that can be overridden in derived contracts
// override functions are functions that override a function in a base contract
pragma solidity >=0.7.0;
contract A {
uint public x = 10;
function getX() virtual public view returns(uint) {
return x;
}
}
contract B is A {
uint public y = 20;
function getY() public view returns(uint) {
return y;
}
}
contract C is A {
uint public z = 30;
function getZ() public view returns(uint) {
return z;
}
function getX() public view override returns(uint) {
return x + 1;
}
}
contract D is B, C {
function getSum() public view returns(uint) {
return x + y + z;
}
}