Dynamic Casting in C++

Do this at first: Virtual Dispatch in C++

Dynamic Casting at Run-Time

works with pointers and refs (you need a vtable and all this), which is more expensive. But it's safe. If bad cast happens, it simply return a nullptr

rtti required