[gameprogrammer] Re: calling class member from another class

Correct me if I'm wrong, but, would you need to put a pointer to it anywhere 
if it's a singleton?
Doesn't a singleton operate in global space, allowing you to call its 
functions from anywhere?
The texture manager that I made for one of my games was a singleton, and I 
didn't need to store a pointer to it anywhere. If I needed the manager, I 
just included the header file to it and started using it right off the bat.

Kevin

From: Justin Coleman <jmcoleman@xxxxxxxxx>
Reply-To: gameprogrammer@xxxxxxxxxxxxx
To: gameprogrammer@xxxxxxxxxxxxx
Subject: [gameprogrammer] Re: calling class member from another class
Date: Sat, 16 Oct 2004 22:11:58 -0400

Thanks Carlos, you got it exactly right.

I ended up making the texture manager a singleton and putting a
pointer to it in the object class, and using the pointer to access the
texture add function.

For anyone who doesn't already have a reference on this:

Singleton definition and example code:
http://www.gamedev.net/dict/term.asp?TermID=1195 and
http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=148

Class pointer definition and example code:
http://www.cplusplus.com/doc/tutorial/tut4-1.html (at the bottom of the 
page)

Hope this helps others, even with the right answer at hand this was a
bear to wrap my head around.

-Justin


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




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


Other related posts: