struct init property

nocide benutzer at example.com
Fri Aug 24 00:39:21 PDT 2012


Am 23.08.2012 19:15, schrieb nocide:
> struct has no default constructor and instances are initialized with the
> init property.
> Can I declare or override the init property for a custom defined struct?
>

Ok, the initializer forks fine for me,
but I've encounterd following situation: (simplified code)

// This compile fine
struct Foo {
     union {
         struct {
             int a = 1, b = 2, c = 3, d = 4;
         }
         float[4] e;
     }
}


// but this doesn't compile
struct Foo {
     union {
         struct {
             int a, b, c, d;
         }
         float[4] e = [ 1.0f, 2.0f, 3.0f, 4.0f ];
     }
}
Foo f;  // Error: struct main.Foo overlapping initialization for struct


Is this a bug?




More information about the Digitalmars-d-learn mailing list