Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Passing a value into a bound class.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
22 replies to this topic

#21 Jake Albano   Members   -  Reputation: 607

Like
0Likes
Like

Posted 30 September 2012 - 08:54 AM

My pleasure! Glad I could help you out. :)

Sponsor:

#22 saejox   Members   -  Reputation: 714

Like
-1Likes
Like

Posted 30 September 2012 - 03:27 PM

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. Posted Image


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

now only Game::EndGame() can call delete on singleton. applies to "get" and any other functions too.

#23 Jake Albano   Members   -  Reputation: 607

Like
0Likes
Like

Posted 30 September 2012 - 07:56 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS