title: C++ - Map iterator access results in segfault
body: <p>I tried to reformulate the question completely. The situation is as follows : </p>
  
  <pre><code> class Departure {
      private :
        unsigned int supply;
  
      public : 
       Departure(int);
       ~Departure();
       int getSupply()  {
         return supply;
       };
  };
  
  
  class Route {
      private :
         Departure* departure;
      public :
         Departure&amp; getDeparture() { 
            return *departure;
          };
  };
  
  class Plan {
      private :      
         std::map&lt;Route*, double&gt; quantities;
      public :
         void addRoute(Route&amp; rt)  {
            quantities.insert(std::pair&lt;Route*,double&gt;(&amp;rt,0));
          };
  
         void createSolution() {  
            std::map&lt;Route*, double&gt;::iterator it;    
            for(it = quantities.begin(); it != quantities.end(); ++it) {      
               it-&gt;second = it-&gt;first-&gt;getDeparture().getSupply();                        
             };
  };
  </code></pre>
  
  <p>After the routes are added - i have checked, it works OK, i get a segfault which from my trial &amp; error up to now is situated in the <code>it-&gt;first-&gt;getDeparture().getSupply()</code> call. Any explanation why?</p>