Classes on stack
Dennis
dkorpel at gmail.com
Thu Sep 1 09:40:06 UTC 2022
On Thursday, 1 September 2022 at 09:13:56 UTC, Redwan wrote:
> I want declare classes and create instance of them on stack and
> nicely use them.
You can use that using the `scope` storage class on a local
variable with a class type:
https://dlang.org/spec/attribute.html#scope-class-var
```D
void main() @nogc
{
scope o = new Object();
}
```
The `@nogc` attribute ensures no allocations are made with the
Garbage Collector.
More information about the Digitalmars-d
mailing list