title: Calling member functions of an object stored in a vector
body: <p>This may sound like a newbie question. How do I call a member function of an object stored in a vector ? Supposedly, I have this class:</p>
  
  <pre><code>class A {
  public:
  void foo() {
  std::cout &lt;&lt; "Hello World"; }
  };
  </code></pre>
  
  <p>Then I store some objects in a vector:</p>
  
  <pre><code>std::vector&lt;A*&gt; objects;
  A* b;
  A* c;
  A* d;
  
  objects.push_back(b);
  objects.push_back(c);
  objects.push_back(d);
  </code></pre>
  
  <p>Now I want to create a loop, in which every object stored in the vector would call it's own foo() function. How should I do this ? At first I thought I could just do something like this:</p>
  
  <pre><code>objects[2].foo();
  </code></pre>
  
  <p>But it seems that I can't do it like this.</p>