Static_cast, the forced type conversion operator in the C syntax can also be completed. But then again, what the forced type conversion in C can do is not always done, for example, remove the const.
In addition, it is declared that the average person will not be aware of it, that is, only one of the four can be used for non-pointer non-reference type conversion, the other three operators are basically dealing with pointers or references.
Const_static: remove the const, volatile, and _ unaligned attributes of "Pointer" or "Reference. Many people think that using this operator can make const something so "solid" as a false one. In fact, it is not the case. In essence, it can only remove a layer of false shell for you, if the things that are "pointed" or "referenced" are const itself, it is futile for you to make too much effort. It is generally used in such a set of logic:
Int A = 34; const int * pcint = & A; int * pint = const_cast <int *> (pcint); * pint = 0; in this way, the const Pointer "This pointer requires that it cannot be changed to the stuff it points to" is modified. If it is changed to const int A = 34 here, although the compilation still works, the operation is still OK, but when you use * pint to modify it, you will get the modified value: A is still 34, and * pint is indeed 0, however, it is interesting that pint = & A is still valid at this time. Although pint points to a, its value is not equal to. So far, I hope you will not misuse const_cast in the future.
Dynamic_cast: In a refined language, it is specifically used for down cast in object oriented. However, there are three prerequisites: first, it must be used for conversion between classes and subclasses; second, it must be used for conversion of pointers or reference types; and third, the base class must have virtual functions.
Reinterpret_cast: Used to reencapsulate pointers, that is, convert between pointer classes. In addition, it can be used to convert between pointer types and unsigned int types.
Some static_cast const_cast