Operator "+=" overloading for class?

novice2 sorryno at em.ail
Mon Dec 18 04:49:53 UTC 2023


On Monday, 18 December 2023 at 03:39:16 UTC, Ki Rill wrote:
> On Sunday, 17 December 2023 at 07:05:12 UTC, Adam D. Ruppe 
> wrote:
>> On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote:
>>> [...]
>>
>> check what `op` is. pretty sure it is "+" not "+=" so your 
>> element isnt' saved anywhere. also a bit iffy there isn't a 
>> member here to work on
>
> Yes, op is '+'. What do you mean by it isn't saved anywhere?

your code just return result value,
but it should not return but save result to "this"
see example at 
https://dlang.org/spec/operatoroverloading.html#index_op_assignment




More information about the Digitalmars-d-learn mailing list