Question regarding singletons

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Question regarding singletons

Post by Ginto8 »

I was wondering, if you had a singleton that was really the main control center for a program, and you really only had to call start(), which would take care of all the stuff that has to be done, could you do something like this, presuming that Main::get_instance()'s return type was Main*?

Code: Select all

Main::get_instance()->start()
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Question regarding singletons

Post by MarauderIIC »

Yes. Although we use references, so we occasionally do something like Main::getInstance().start(); usually if we don't need to reference it more than once (like a debug call or a call to the text engine or something)
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Post Reply