Skip to main content
GameDev.net gamedev.net
🔒 Locked

Derived singletons

Started by Terren Apr 26, 2003 at 2:23 AM 0 replies 300+ views
Original Post
Terren
Terren
Hi I''ve just come across a problem with a singleton class that I have just made, which is everything works as it should until I derive a new class from it and try to override a function - the problem being that it still calls the base function even tho it''s been overridden with a new one. I understand why this happens, being the nature of a singleton, but is there a way to get around this? Or am I going to have to rethink my strategy as far as using singletons is concerned? Actually, I think i''ve got around it, but i''m not sure whether this is a) an elegant solution b) defying the point of using a singleton What I did was to derive a new class from the base singleton class, then in the constructor, create the singleton. In the destructor, i deleted the singleton. Then in the main app space, I simply created a new instance of the derived class, and used it/delete it as normal. Do I win?
billybob
billybob
have the base have a ''CreateInstance'' function, with an argument of which class you want to create.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.