1

solidity | 函数继承

 1 year ago
source link: https://benpaodewoniu.github.io/2023/02/19/solidity60/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

solidity | 函数继承 | 犀牛的博客

姑苏城外一茅屋,万树梅花月满天

函数继承分为

子合约需要调用父合约的构造函数。

如果父合约构造函数有参数,那么子合约需要提供参数调用父合约。

两种调用,一个是在声明中直接赋值,一个是像修饰器一样,调用时再赋值。

pragma solidity ^0.4.18;

contract A{

constructor(uint a){}

}

contract B is A(5){

function hello() public{
}
}
pragma solidity ^0.4.18;

contract A{

constructor(uint a){}

}

contract B is A{

constructor(uint s) A(s + 1){}

}

上面传递给父合约的构造函数的参数可以进行修改。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK