parameter-less "default" struct constructor not allowed--why?
Christopher the Magnificent
ultimatemacfanatic at gmail.com
Fri May 20 16:09:17 PDT 2011
On 5/20/11 4:25 PM, Andrej Mitrovic wrote:
> You can override opCall(). I don't know how people feel about using
> that sort of thing, but it works for me (I rarely need it though).
If I override opCall(), will I be able to use that will operator "new"
to do BOTH of the following?
1. MyStruct ms1 = MyStruct(); // calls opCall to initialize on stack
2. MyStruct* ms2 = new MyStruct(); // calls opCall() to init on heap
It seems that #2 does not work on my machine.
What this suggests to me is that opCall override and using keyword "new"
do not mix. Would you agree?
This leads me back to my original question.
*Why* are zero-parameter struct constructors disallowed? Any insight or
speculation?
If there are no valid reasons for this limitation, then perhaps its
ought to be lifted.
What do you think, Mr. Mitrovic, or anyone?
-- Christopher
More information about the Digitalmars-d-learn
mailing list