[gameprogrammer] Re: calling class member from another class

On Sun, 17 Oct 2004 10:23:01 -0300, Kevin Fields
<drunkendruid@xxxxxxxxxxx> wrote:
> 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
> 

That's what I thought too, but MSVC.net wouldn't let me do it.
Singleton or not, I had to have an instance of it already constructed
in order to call a function. The compiler wouldn't let me put a
function call to it inside another class without having the pointer,
for some reason.

By "inside another class" I mean within a member funtion of the object
class that I've got, and each class has its own separate cpp and h
files, much as I loathe having tons of source files. That may be the
reason, the singleton wasn't being constructed until inside the main
function, thus when the other class code was included it didn't exist
yet?

The pointer works though, and that's the important thing right now :)

-Justin


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


Other related posts: