Question: > 
> **Possible Duplicate:**  
> 
> [Regular cast vs. static\_cast vs. dynamic\_cast](https://stackoverflow.com/questions/28002/regular-cast-vs-staticcast-vs-dynamiccast) 
> 
> 
> 

I don't quite get when to use static cast and when dynamic. Any explanation please?

Answer: 
In some contexts, like this one, "static" refers to compile-time and "dynamic" refers to run-time.

For compile-time checking, use static\_cast (limited to what the compiler knows).
For run-time checking, use dynamic\_cast (limited to classes with RTTI).
For no checking, use reinterpret\_cast.
Static casting is done by the compiler: it treats the result as the target type, no matter what. You do this when you're absolutely sure about the argument being of the target type.

Dynamic casting is done at runtime, and thus requires runtime type information. You do this when you're unsure about the type you have: the cast may fail, which is shown by the return value being null. It can also only be done for pointers and references.