mercredi 1 juillet 2015

Define an object in a .cpp file

Header file

class Universe
{
    public:
        Universe();
        ~Universe();

    private:
        ChunkManager chunkManager;
};

I want to initialize chunkManger without using the default constructor. However, the constructor I want to use takes an object. How do I make the chunkManager object to use the correct constructor in the .cpp file? So I want something like this:

Universe::Universe(){

    world = new b2World(b2Vec2(0, 0));
    world->SetAllowSleeping(false);

    //I want something like this because the constructor I want takes a World object
    chunkManager = new ChunkManager(world);

    player = new Player(world);
}

Aucun commentaire:

Enregistrer un commentaire