On Saturday, April 4, 2020 4:22:29 AM MDT Robert M. Münch via Digitalmars-d-
learn wrote:
> D doesn't have implicit operators for structs?
>
> struct S {float a, float b};
> S a = {1, 5};
> S b = {2, 5);
>
> a += b;
> Error: a is not a scalar, it is a S
>
> So I really have to write an overloaded operator for such cases?

You could just use the constructor syntax. e.g.

S a = S(1, 5);
S b = S(2, 5);

- Jonathan M Davis




Reply via email to