1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Static pointer definition syntax

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

  1. autumnms

    autumnms New Member

    Joined:
    Jul 30, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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

    Joined:
    Jul 30, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Also, instead of using a pInstance pointer, I use a pInstance object
    what will be the pInstance definition
     

Share This Page