It touches on the topic of downcasting (cast a derived class to its base class)
First of all, downcasting itself is usually unnecessary in most situation where the virtual functions are suffice.
If it must be done, use dynamic_cast. It will return null if cast is unsuccessful