Original Post
im trying to learn how to use singletons so i dont have to link so many of my manager classes using pointers. but im getting this error: error C2228: left of '.Display' must have class/struct/union Shouldn't Singleton::Instance.Display(); work? and call the display data? Thanks to all in advance =)
class Singleton
{
public:
static Singleton& Instance()
{
static Singleton theSingleton;
return theSingleton;
}
/* more (non-static) functions here */
void Display()
{
cout << "yay it works" << endl;
}
private:
Singleton(); // ctor hidden
Singleton(Singleton const&); // copy ctor hidden
Singleton& operator=(Singleton const&); // assign op. hidden
~Singleton(); // dtor hidden
};
void main()
{
Singleton::Instance.Display();
int stopper;
cin >> stopper;
}