为什么构造函数必须具有公开性而不是内部可见性?

问题描述

仅初始化合同,我不明白为什么它不是内部函数。这样,安装公共功能的气体成本就更便宜了

来自solidity的API:

 // This is the constructor which registers the
        // creator and the assigned name.
    constructor(bytes32 _name) public {
            // State variables are accessed via their name
            // and not via e.g. `this.owner`. Functions can
            // be accessed directly or through `this.f`,// but the latter provides an external view
            // to the function. Especially in the constructor,// you should not access functions externally,// because the function does not exist yet.
            // See the next section for details.
        owner = msg.sender;
    
        // We do an explicit type conversion from `address`
        // to `TokenCreator` and assume that the type of
        // the calling contract is `TokenCreator`,there is
        // no real way to check that.



 creator = TokenCreator(msg.sender);
    name = _name;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)