LoginSignup
4
0

More than 5 years have passed since last update.

Solidityで親要素のコンストラクタに引数を渡す方法

Posted at

Solidityでは継承元のコンストラクタに引数を渡す方法が2つあります。

contract Parent {
    uint x;
    constructor(uint _x) public { x = _x; }
}

// 直接継承元に引数を渡す方法
contract Chaild1 is Parent(7) {
    constructor() public {}
}

// modifierで親要素のコンストラクタに引数を渡す方法
contract Chaild2 is Parent {
    constructor(uint _y) Parent(_y) public {}
}

引数を渡さなければそのまま抽象化となります。

詳しくはSolidity公式ドキュメント最新版(v0.5.4)を参照してください。

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0