Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Static pointer definition syntax (http://www.go4expert.com/forums/static-pointer-definition-syntax-t5542/)

autumnms 30Jul2007 10:58

Static pointer definition syntax
 
I am trying to a singleton mymap class. I have declared a private *pInstance pointer. I am having problems in defining the pInstance pointer. Somehow I am not getting the syntax right. Please help me define the pInstance pointer. I tried this definition

template<> assoc<string, string>::*pInstance;


Code:


template<class A, class B>
class myclass
{
public:
....

private:
  static myclass<A, B> *pInstance;

 myclass()
 {
      if(pInstance==NULL)
            pInstance = new myclass<A, B>;
  }


};


template<> assoc<string, string>::*pInstance;
//this is giving errors during build

try.cpp

Code:

typedef myclass<string, string> StrStrMap;

int main()
{
  StrStrMap a;
    ....
}


autumnms 30Jul2007 14:09

Re: Static pointer definition syntax
 
Also, instead of using a pInstance pointer, I use a pInstance object
what will be the pInstance definition


All times are GMT +5.5. The time now is 15:20.