Using std.stdio.File in a class

Rene Zwanenburg renezwanenburg at gmail.com
Tue Apr 8 08:15:35 PDT 2014


On Tuesday, 8 April 2014 at 15:08:17 UTC, Spacen Jasset wrote:
> On Tuesday, 8 April 2014 at 14:53:56 UTC, Adam D. Ruppe wrote:
>> On Tuesday, 8 April 2014 at 14:52:02 UTC, Spacen Jasset wrote:
>>> Are you not supposed to new structs anymore?
>>
>> Only if they're pointers. new File returns a File*, not a File.
>>
>> But you shouldn't new a File because then the file won't be 
>> automatically closed when it goes out of scope (RAII indeed).
>>
>> Your code should work if you just take out the new keyword.
>
> Perhaps the new keyword doesn't do what it used to do? I'll 
> have to check all this out.

Maybe you're confused with C#? In C# you have to use new for 
structs too. In D new allocates something on the GC heap.


More information about the Digitalmars-d-learn mailing list