title: BOOST and C++: can't seem to get polymorphism to work
body: <p>I'm using ptr_vector to store "shapes". I'm trying to fill it with derived shape classes, such as "circles", and every time I try to downcast them I get bad cast.</p>
  
  <pre><code>class Shape
  {
  public:
      virtual ~Shape() {};
      virtual void print() { std::cout &lt;&lt; "shape" &lt;&lt; std::endl; };
  };
  
  class Circle :
      public Shape
  {
  public:
      void print() { std::cout &lt;&lt; "circle" &lt;&lt; std::endl; };
  };
  
  int main()
  {
      boost::ptr_vector&lt;Shape&gt; shapes;
      shapes.push_back(new Circle);
  
      BOOST_FOREACH(Shape shape, shapes)
      {
          Circle&amp; tempCircle = dynamic_cast&lt;Circle&amp;&gt;(shape);
          if(&amp;tempCircle != NULL)
              tempCircle.print();
      }
  
      system("PAUSE");
  }
  </code></pre>