pragma solidity 0.8.0;
contract getter{
//1、public 修饰符默认生成get方法
uint public num = 100;
//2、当写了这个函数、等价瑜上面的的函数方法、默认的函数就会消失、瑜上面重复会报错
function num() external view returns(uint){
return num;
}
//3、默认生成的get函数的是external权限的、不能在合约内部调用
function test1(){
this.num();
}
mapping(uint => string) public map;
//mapping 默认生成下面的函数
//function map(uint key) external returns(string){
//}
function test2(){
map[2] = "xiehuangbao";
}
function test3()returns(string){
return this.map(2);
}
mapping(uint => mapping(uint => mapping1(uint => string))) public map;
function test4(){
map[0][1][2] = "蟹黄堡";
}
}
35.Solidity-默认生成的函数
最新推荐文章于 2024-08-16 23:45:34 发布