Constructors not working

Tejas notrealemail at gmail.com
Sat Sep 3 05:11:11 UTC 2022


On Friday, 2 September 2022 at 18:39:27 UTC, rikki cattermole 
wrote:
> I think you are wanting opAssign not opBinary.
>
> Also you made a mistake, since its a struct you don't want to 
> new it when you construct and return it.
>
> ```d
> return new Time(secos / 3600, (secos % 3600) / 60, secos % 60);
> ```
>
> Would be a ``Time*`` not ``Time`` which is what you returned.

And shouldn't an `opAssign` be `void` anyways? Doubt there's many 
people writing stuff like `auto c = (a = b);`, where `a` is a 
`struct`/`class`.


More information about the Digitalmars-d-learn mailing list