I expect the following code below to create 10 items with 10 different addresses, instead they all have the same address?

import std.stdio;

class Bob {
}

void main()
{
    for (auto i = 0; i < 10; i++) {
        auto pBob = bobFactory();
        writefln("bob @ %x\n", pBob);
    }
}

Bob *bobFactory() {
    Bob bob = new Bob;
    Bob *pBob = &bob;

    return pBob;
}

Reply via email to