[gameprogrammer] problem with singleton
- From: "Roger D. Vargas" <roger@xxxxxxxxxxx>
- To: Game programmer list <gameprogrammer@xxxxxxxxxxxxx>
- Date: Mon, 14 Jun 2004 11:05:05 -0400
I tried to implement the cache class as a singleton. Here is the code:
class TVTextures {
public:
static TVTextures getCache() { return _instance; };
~TVTextures();
protected:
TVTextures();
static TVTextures _instance;
};
But whenever I try to use the class like this:
TVTextures::getCache().AddImage(STSTR,driver->getTexture("strength_i.jpg"));
i got an error a linking error: undefined reference to
`tower::TVTextures::_instance'
if I change _instance to be a pointer and the getCache code to try make
sure the pointer is initialized to this:
static TVTextures getCache() {
if (_instance==0) _instance= new TVTextures(); <---
return _instance; };
then I get the same error, but in the marked line. What Im doing wrong?
--
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
- Follow-Ups:
- [gameprogrammer] Re: problem with singleton
- From: Ludovic Famechon
- [gameprogrammer] Re: problem with singleton
- From: Dave Slutzkin
Other related posts:
- » [gameprogrammer] problem with singleton
- » [gameprogrammer] Re: problem with singleton
- » [gameprogrammer] Re: problem with singleton
- » [gameprogrammer] Re: problem with singleton
- » [gameprogrammer] Re: problem with singleton
- [gameprogrammer] Re: problem with singleton
- From: Ludovic Famechon
- [gameprogrammer] Re: problem with singleton
- From: Dave Slutzkin