title: deleting memory allocated in static function in C++
body: <p>I have C++ class as follows</p>
  
  <pre><code>class anotherClass;
  
  class myClass {
     private:
      myClass() {}
      ~myClass() {}
  
      typedef std::map&lt;string, anotherClass* &gt; stringToClass;
          static stringToClass s_stringToClass;
  
      public:
           static anotherClass* getStringToclass(string name);
  
  };
  </code></pre>
  
  <p>in above class for getStringToClass defintion is as follows</p>
  
  <pre><code>anotherClass* myClass::getStringToClass(string name) {
       stringToClass::iterator iter;
       iter = s_stringToClass.find(name);
  
       if(iter == s_stringToClass.end()) {
            typedef stringToClass::value_type stringToClassPair;
            anotherClass* pothClass = new anotherClass();
            s_stringToClass.insert(stringToClassPair(name, pothClass));
            return pothClass;
       }
       else {
          return iter-&gt;second;
       }
  }
  </code></pre>
  
  <p>now my question is we are allocating memory in static function as defined above. How can we delete memory? Can we delete memory in destructor, as destructor is not static?</p>
  
  <p>Thanks for the help.</p>