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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -