Passing a value into a bound class.

Started by
21 comments, last by TechRogue 11 years, 7 months ago
My pleasure! Glad I could help you out. :)
Advertisement

I strongly suggest you read this article: http://gameprogrammi.../singleton.html Singletons have a lot of attractive features at first glance, but they're really a bad idea in the long run.

I do understand the difference between a plain global and the singleton pattern, but functionally they serve the same purpose of providing global access to the same variable anywhere in your program. Additionally, my engine is designed so I could have multiple instances of it running in the same program. Using a singleton for the engine would prevent me from doing this.

As far as malicious use goes (although I'm not sure why that would ever be a concern), your singleton example above is just as susceptible:


delete Engine::get();


To each his own. Let's not go any further off topic. smile.png



protected:
friend void Game::EndGame();
~Engine();


now only Game::EndGame() can call delete on singleton. applies to "get" and any other functions too.
Come on now, this isn't the place for this discussion. You're not going to convince me that Singletons are a good idea, and I'm clearly not going to convince you that they're a bad one. Just let it go.

This topic is closed to new replies.

Advertisement