`This` reference not accessible when overloading an operator?

Steven Schveighoffer schveiguy at gmail.com
Tue Jan 21 21:44:11 UTC 2020


On 1/21/20 3:48 PM, Enjoys Math wrote:
> I have an Integer class in integer.d.  A RationalNumber class in 
> rational_number.d, and they each import each other (so that could be the 
> issue).  However, this is not working:
> 
> 
>     Symbol opBinary(string op : "/")(const Integer z) const
>     {
>        return new RationalNumber(this, z);
>     }
> 
> Getting:
> 
> Error: class `rational_number.RationalNumber` member `this` is not 
> accessible
> Error: template instance `integer.Integer.opBinary!"/"` error instantiating
> 

Do you have a static somewhere that's affecting this? A more complete 
code example might help.

-Steve


More information about the Digitalmars-d-learn mailing list