250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- concept
- error
- Interface
- node.js
- useState
- middleware
- built in object
- API
- solidity
- 기준
- express.js
- Redux
- CLASS
- CSS
- bitcoin
- tailwindcss
- Props
- 삶
- nextJS
- REACT
- hardhat
- SSR
- HTML
- Ethereum
- graphQL
- evm
- JavaScript
- typeScript
- blockchain
- web
Archives
- Today
- Total
ReasonJun
Solidity: Encapsulation 본문
728x90
// SPDX-License-Identifier: MIT
pragma solidity >= 0.7.0 < 0.9.0;
contract Number {
uint private num = 4;
function changeNum() public {
num = 5;
}
function getNum() public view returns (uint) {
return num;
}
}
contract Caller {
Number internal instance = new Number();
function changeNumber() public {
instance.changeNum();
}
function getNumber() public view returns(uint) {
return instance.getNum();
}
}
728x90
'Blockchain > Solidity' 카테고리의 다른 글
Solidity : Overriding (virtual / override / super) (0) | 2023.10.17 |
---|---|
Solidity : Overloading (1) | 2023.10.16 |
Solidity : Inheritance (is, override / Multiple) (0) | 2023.10.16 |
Solidity : Immutable / Constant (0) | 2023.10.16 |
Solidity : constructor (0) | 2023.10.16 |
Comments