Strange compiler error. Whose bug is that?
thedeemon
dlang at thedeemon.com
Sat Jan 27 08:18:07 UTC 2018
On Friday, 26 January 2018 at 21:17:14 UTC, Oleksii Skidan wrote:
> struct Game {
> Triangle player = new Triangle;
When you initialize a struct member like this, compiler tries to
calculate the initial value and remember it as data, so each time
such struct is constructed the data is just copied. Which means
this data must be computable at compile time, however your
Triangle constructor is using pointers to some values, these
pointers will only be known at run time. This means you need to
construct Triangles at run time, in Game constructor, not at
compile time in this initialization syntax.
More information about the Digitalmars-d-learn
mailing list