Singleton class having problem define the definition for singleton private method.

Hi, this singleton class has a private method that I'm having trouble defining in the definition source code.
I have the header file as:
1
2
3
4
5
6
7
8
9
10
class Type
{  
  public:
    ~Type() {}
    
  private:
    Type() {}
    static Type* Instance();
    
};


and the definition file as:
1
2
static Type Type::Instance()]
{}



TextureManager.cpp:3:23: error: prototype for ‘TextureManager TextureManager::Instance()’ does not match any in class ‘TextureManager’
 static TextureManager TextureManager::Instance()
                       ^
In file included from TextureManager.cpp:1:0:
TextureManager.h:17:32: error: candidate is: static TextureManager* TextureManager::Instance()
         static TextureManager* Instance();
Last edited on
Line 8 of your header and line 1 of your definition do not agree.

Your header says Instance() returns a pointer.
You definition says Instance returns an object of type Type.

Your header and definition must agree.

BTW, you have an extraneous ] in your definition.
Topic archived. No new replies allowed.