Compilation error when trying to compile a singleton in c++ -


i'm trying study c++. wrote file "singleton.h" follows:

class singleton { private:     static singleton* m_this;     singleton(); public:      static singleton* getinstance(){         return m_this;     }     virtual ~singleton(); }; 

my singleton.cpp file:

#include "stdafx.h" #include "singleton.h" singleton::singleton(){} singleton::~singleton(){} 

i call in main method getinstance method follows:

singleton* s = null; s = singleton.getinstance(); 

but, compile error:

error c2275: 'singleton' : illegal use of type expression 

do know why that?

s = singleton::getinstance(); 

not ., ::(scope resolution operator) static methods.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -