Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
Posted: Sun Jan 04, 2009 1:48 pm Post subject:
Looks like it makes it so that you can only have 1 object of that class. When you try to make a second object, you get a pointer to the first instead.
If you did "Singleton a, b;", a and b would would just be pointers to the exact same object.
I've never heard of this before, though, so I may be wrong.
Static means that that variable is allocated once during the whole program so if it's called twice, it will be the same var.
msdn wrote:
When modifying a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all instances of the class. When modifying a member function in a class declaration, the static keyword specifies that the function accesses only static members.
private means it can only be accessed by a member of that class. ie, you can't call a.Singleton1(); from the main loop. If it was under public:, then you could. There's also protected: which is like private:, but it cna also be accessed by members of child classes. _________________
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum