contract Base { uint data; constructor(uint _data) public { data = _data; } } contract Derived is Base (5) { constructor() public {} }
可以使用以下方法间接初始化基构造函数
1 2 3 4 5 6 7 8 9 10 11
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 {} }