The dynamic_cast conversion allows for safely converting pointers (and references) to classes up, down, and sideways in the inheritance hierarchy.
From cppreference.com:
Safely converts pointers and references to classes up, down, and sideways along the inheritance hierarchy.
dynamic_cast
has usage scenarios and limitations. In general terms this amounts to it being valid for casting polymorphic types and it performs run-times checks to ensure that the result is valid for the requested object type.