1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Static pointer definition syntax

Discussion in 'C' started by autumnms, Jul 30, 2007.

  1. autumnms

    autumnms New Member

    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;
        ....
    }
    
    
     
  2. autumnms

    autumnms New Member

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

Share This Page