-
Notifications
You must be signed in to change notification settings - Fork 1
/
S03L14 - Sol6_ex2_override.sol
66 lines (54 loc) · 1.31 KB
/
S03L14 - Sol6_ex2_override.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
pragma solidity >=0.5.15 <=0.6.0;
/**
* https://solidity.readthedocs.io/en/v0.6.0/060-breaking-changes.html#explicitness-requirements
* Functions can now only be overridden when they are either marked with the virtual keyword or
* defined in an interface. Functions without implementation outside an interface have to be marked virtual.
* When overriding a function or modifier, the new keyword override must be used. When overriding a function
* or modifier defined in multiple parallel bases, all bases must be listed in parentheses after the keyword
* like so: override(Base1, Base2).
*
* */
/**
* Works in Solidity 0.5.15
*
* *
contract A {
event MyEvent(string _myString);
function funA() public {
emit MyEvent("from A");
}
}
contract B {
function funA() public {
//does nothing
}
}
contract C is B,A {
function funA() public {
emit MyEvent("from B");
super.funA();
}
}
/**/
/**
* works in 0.6.0
* */
contract A {
event MyEvent(string _myString);
function funA() public virtual {
emit MyEvent("from A");
}
}
contract B {
function funA() public virtual {
//does nothing
}
}
contract C is A,B {
function funA() public override(B,A) {
emit MyEvent("from B");
super.funA();
}
}
/**
* */