基于以太坊的智能合约开发教程Solidity 多重继承
pragma solidity ^0.4.0;
contract testOne {
uint money =100;
uint height =188;
function dance()public pure returns(string){
return "one dance";
}
}
contract testTwo {
uint money =200;
uint height = 165;
function dance()public pure returns(string){
return "two dance";
}
}
// 当合约多重继承时,并且有重复的属性需要继承的时候,以继承的最后一个合约里的属性为主
contract test is testOne,testTwo{
uint height = 177;
// 当合约本身也有与继承合约相同的属性时,使用的是合约本身的属性
function getMoney()public view returns(uint){
return money; // 200
}
function getHeight()public view returns(uint){
return height; // 177
}
function getDance()public pure returns(string){
return dance(); // "two dance"
}
}