Operator overloading question

Nathan M. Swan nathanmswan at gmail.com
Sun Jan 20 22:51:20 PST 2013


On Monday, 21 January 2013 at 06:19:47 UTC, Joseph Cassman wrote:
> Please refer to http://dpaste.dzfl.pl/edit/b73ef2cd
>
> The code is contrived but is trying to focus on overloading the 
> "+" and "*" operators for a struct.
>
> Here is the output.
>
> /home/c215/c527.d(36): Error: incompatible types for ((x) + 
> (y)): 'Arithmetic!(int)' and 'Arithmetic!(int)'
> /home/c215/c527.d(37): Error: 'x' is not of arithmetic type, it 
> is a Arithmetic!(int)
> /home/c215/c527.d(37): Error: 'y' is not of arithmetic type, it 
> is a Arithmetic!(int)
>
> I am trying to understand why there are errors at all.
> Also why the error for line 36 is different from the error for 
> line 37.
>
> Thanks
>
> Joseph

The correct keyword is "opBinary", not "opbinary". Also, that's a 
link to editing the paste, viewing it is:

http://dpaste.1azy.net/b73ef2cd


More information about the Digitalmars-d-learn mailing list