dlang语言中,类的opAssign方法是重载赋值运算符的方法,但是在该方法中不能使用类的标识符。因此,您需要将代码中的类标识符替换为this关键字,以避免该错误。修改后的代码如下:

class PhpValue {
    private string value;

    this(string value) {
        this.value = value;
    }

    this(PhpValue other) {
        this.value = other.value;
    }

    void opAssign(PhpValue other) {
        this.value = other.value;
    }
}
dlang语言最新dmd2103版本以下代码我实现一个类的opAssign方法的时候报错如下帮我纠正Error class a_2PhpValue identity assignment operator overload is illegal

原文地址: https://www.cveoy.top/t/topic/fiVv 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录