[gameprogrammer] Re: making a global instance

Use a singleton

class Application
{
 public:
 Application();
 ~Application();
 static Application* Instance(void) {return &instance;}
 
 protected:
 static Application instance;
};

Application Application::instance;

----- Original Message ----- 
From: "Roger D. Vargas" <roger@xxxxxxxxxxx>
To: "Game programmer list" <gameprogrammer@xxxxxxxxxxxxx>
Sent: Saturday, June 12, 2004 4:40 AM
Subject: [gameprogrammer] making a global instance


> I have a problem with my project, I want to have all images, scene nodes
> and sounds stored in caches, to avoid repeated resources consuming
> memory. I need to make those caches available to all game components,
> like the gui, character entities, etc. Something like a global variable.
> But of course I want to avoid declaring that instance as a global
> variable or passing the cache as parameter to all constructors. Can
> somebody give me an idea? Im using C++.
> 
> -- 
> Roger D. Vargas
> Linux User: 180787
> ICQ: 117641572
> jabber.ehtsc.co.cu: roger
> "Object-oriented programming is an exceptionally bad idea which could
> only have originated in California." 
> - E.W. Dijkstra
> 
> 
> 
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> 
> 
> 
> 


---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: