title: How come accessing derived class member in base class pointer vector returns an error?
body: <p>Streamlined Example of the problem:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;deque&gt;
  #include &lt;iostream&gt;
  
  class Action{
      public:
      std::string name;
  
      Action(std::string name){
          this-&gt;name = name;
      }
  };
  
  class Ability : public Action{
  public:
      int bar;
      Ability(std::string name) : Action(name){}
  };
  
  int main(){
      std::deque&lt;Action*&gt; foo;
  
      Ability test("asdf");
      test.bar = 122;
  
      foo.push_back(&amp;test);
      std::cout &lt;&lt; foo.at(0)-&gt;bar &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>This creates an error, that there is no 'bar' member of 'Action'.</p>
  
  <p>I realise that this relates to object slicing and I've attempted to use pointers, which allows the vector to push back the 'Ability' object but I cannot access its 'bar' member.</p>
  
  <p>What am I missing?</p>