We can use Polymorphism (inheritance + virtual functions) in order to generalize different types under a common base-type, and then refer to different objects as if they wer
It allows you to do things which you can only do to the derived type. But this is usually a hint that a redesign is in order.
struct Foo { virtual ~Foo() {} }; struct Bar : Foo { void bar() const {} }; int main() { Foo * f = new Bar(); Bar* b = dynamic_cast(f); if (b) b->bar(); delete f; }