-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInherit
51 lines (27 loc) · 971 Bytes
/
Inherit
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
pragma solidity ^0.4.0;
contract grandfather{
uint public gudong = 200;
function zhongdi() returns(string){
return "Heiyoyo...";
}
}
contract father is grandfather{
uint public money = 10000;
function dahan() returns(string){
return "Zzzzz.....";
}
}
contract son is father{
function getMoney() returns(uint){
return money;
}// son inherits variable money from father
function maobing() returns(string){
return dahan();
}// son inherits function dahan() from father
function getGudong() returns(uint){
return gudong;
}// gudong is inherited from father from grandfather, it is a case of successive inheritant
function work() returns(string){
return zhongdi();
}// zhongdi() is inherited from father, from grandfather
}