📅  最后修改于: 2020-11-04 04:29:03             🧑  作者: Mango
构造函数是使用构造函数关键字声明的特殊函数。这是一个可选功能,用于初始化合同的状态变量。以下是构造函数的关键特征。
pragma solidity ^0.5.0;
contract Test {
constructor() public {}
}
pragma solidity ^0.5.0;
contract Base {
uint data;
constructor(uint _data) public {
data = _data;
}
}
contract Derived is Base (5) {
constructor() public {}
}
pragma solidity ^0.5.0;
contract Base {
uint data;
constructor(uint _data) public {
data = _data;
}
}
contract Derived is Base {
constructor(uint _info) Base(_info * _info) public {}
}