parameter-less "default" struct constructor not allowed--why?
Christopher the Magnificent
ultimatemacfanatic at gmail.com
Fri May 20 15:11:56 PDT 2011
Why are parameter-less struct constructors not allowed?
I have a struct that doesn't need vtable or inheritance or anything, but
I want to automatically call a method on it when it's created.
I also want to create this struct on the heap using operator "new".
Is there any way I can keep this struct as a struct (rather than a
class) and still be able to allocate it and initialize it (including
execution of my setup code) in a single statement, a la the following?
MyStruct* ms = new MyStruct();
Maybe I'll have to introduce a dummy parameter in order to be include a
struct constructor. You think so?
What is the rationale to D's not permitting parameter-less "default"
struct constructors?
More information about the Digitalmars-d-learn
mailing list