samedi 26 août 2017

Object property sibling access

I'm making a game with a debugging console. It is structured like:

class Game
{
    bool debugMode;
    // ...
    std::unique_ptr<Loop> loop;
    std::unique_ptr<Debugger> debugger;
    // ...
}

It works great in the class functions:

void Game::init()
{
    // ...
    loop = std::make_unique<Loop>();

    if (debugMode)
    {
        debugger = std::make_unique<Debugger>();
        debugger->console->write(L"Game initialized."); // works great!
    }
}

But what if I want to write something to the console in loop?

  • I don't want to pass debugger to loop.
  • I don't want to create another debugger in loop.

How do I give loop access to debugger?

Aucun commentaire:

Enregistrer un commentaire