Classes in D and C++
Lionello Lunesu
lio at lunesu.remove.com
Mon Mar 5 06:21:09 PST 2007
Lionello Lunesu wrote:
> Walter Bright wrote:
>> Uno wrote:
>>>> Its not possible it seems to do e.g this:
>>>>
>>>> X x(3);
>>>>
>>>> rather you have to do:
>>>>
>>>> X x = new X(3);
>>>
>>> Yep, I don't like that syntax too. Everywhere news.. And although D
>>> has many great features such small things prevent me to switch to D.
>>>
>>
>> You can do:
>>
>> auto x = X(3);
>>
>> and x will be put on the stack.
>
> Uh, I think this one should go on the eater-eggs list!?
>
> I've read the docs on "Allocating Class Instances On The Stack" but I
> had no idea you could instantiate classes without 'new'! I love it!
Uhm I think you'll still need a struct + static opCall for this to work.
L.
More information about the Digitalmars-d
mailing list