| Home | Libraries | People | FAQ | More

## `polymorphic_downcast` example

    #include <boost/polymorphic_cast.hpp>
    ...
    class Fruit { public: virtual ~Fruit(){}; ... };
    class Banana : public Fruit { ... };
    ...
    void f( Fruit * fruit ) {
      // ... logic which leads us to believe it is a Banana
      Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
      ...
    }