D Language Memory & Pointers Allocating on the heap


Example

A new memory block on the heap is allocated using the new expression, which returns a pointer to the managed memory:

void main()
{
    int* a = new int;
    *a = 42; // dereferencing
    import std.stdio : writeln;
    writeln("a: ", *a);
}