title: C++11 smart pointers and polymorphism
body: <p>I'm rewriting an application using c++11 smart pointers. </p>
  
  <p>I have a base class:</p>
  
  <pre><code>class A {};
  </code></pre>
  
  <p>And a derived class:</p>
  
  <pre><code>class B : public A {
    public:
    int b;
  };
  </code></pre>
  
  <p>I have another class containing a vector with either A or B objects:  </p>
  
  <pre><code>class C {
    public:
    vector&lt;shared_ptr&lt;A&gt;&gt; v;
  };
  </code></pre>
  
  <p>I have no problem constructing C with A (base class) objects but how can I fill it with B (derived class) objects?</p>
  
  <p>I'm trying this:</p>
  
  <pre><code>for(int i = 0; i &lt; 10; i++) {
      v.push_back(make_shared&lt;B&gt;());
      v.back()-&gt;b = 1;
  };  
  </code></pre>
  
  <p>And the compiler returns:
  error: ‘class A’ has no member named ‘b’</p>