contract Father{
constructor(string memory _givenName){
givenName = _givenName;
}
string public familyName = "Lee";
string public givenName = "Dae";
uint256 public money = 100;
function getFamilyName() view public returns(string memory){
return familyName;
}
function getGivenName() view public returns(string memory){
return givenName;
}
function getMoney() view virtual public returns(uint256){
return money;
}
}
contract Son is Father { //생성자를 이용하여 아들이름 변경
constructor() Father("Yong"){
}
uint256 public earning = 0;
function work() public {
earning += 100;
}
function getMoney() view override public returns(uint256){
return money + earning ;
}
}
'솔리디티' 카테고리의 다른 글
상속 (0) | 2022.06.25 |
---|---|
functuion String (0) | 2022.06.25 |
view와 pure (0) | 2022.06.25 |
솔리디티 접근제한자 (0) | 2022.06.25 |
Solidity Function정의 (0) | 2022.06.25 |