Check whether dynamic_cast is successful or not