title: Pointer list c++
body: <p>The code below:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;list&gt;
  class A
  {
      public: 
      void printHello(){std::cout &lt;&lt; "hello";}
  };
  int main(int argc, char *argv)
  {
      std::list&lt;A*&gt; lista;
      lista.push_back(new A());
      for(std::list&lt;A*&gt;::iterator it=lista.begin();it!=lista.end();++it)
      {
          //how to get to printHello method?
          //it doesn't work
          it-&gt;printHello();       
      }   
      return 0;
  }
  </code></pre>
  
  <p>This code doesn't work. My question is how to get to method 'printHello' by iterator it? Thanks.</p>