solidity 中 关键字 this 的理解

比如下面的代码中 this 指的就是 当前代码中 Score合约。

contract Score {
    mapping(address => uint256) score;
    address teacher;

    constructor() {
        teacher = address(new Teacher(address(this)));
    }
}

在当前合约内访问 external 定义的函数的时候需要使用 this 指针。

猜你喜欢

转载自blog.csdn.net/bareape/article/details/123350812