Noob question about structs allocation
Basile B.
b2.temp at gmx.com
Mon Oct 15 03:33:04 UTC 2018
On Monday, 15 October 2018 at 03:19:07 UTC, IM wrote:
> I probably used to know the answer to this question, but it's
> been a long time since I last used D, and I don't remember.
> Suppose we have:
>
> struct S {
> int num;
> }
>
> Would allocating an instance on the heap using:
>
> S* s = new S;
>
> use the GC, or do we have to call destroy() or delete on s
> ourselves?
new is an operator that always allocates using the GC,
calling destroy yourself won't hurt either but is not necessary.
More information about the Digitalmars-d-learn
mailing list