Four kinds of transformation of C ++

1.dymatic_cast <type> (a): a transition between classes meet two forms, a single type, or a parent-child relationship, do checks during operation, failure will return 0 transition and throw bad_cast.

2.static_cast <type> (a): In fact, this cast and the traditional C language is the same, it does not do any checking, if the transition will fail unknown error occurred.

3.const_cast <type> (a): The Switch to a const type from or to a non-const const type Switch type, used to pass parameters.

4.reinterpret_cast <type> (a): may be any transformation, to find a type of memory by way of interpretation, the programmer needs to ensure the accuracy of the conversion.

Published 133 original articles · won praise 8 · views 30000 +

Guess you like

Origin blog.csdn.net/fbher/article/details/100536155