# Include <iostream> using namespace STD; int main () {// 1. const_cast // const int A = 10; // int * PTR = const_cast <int *> (& A); // remove the const attribute // * PTR = 100; // 2. static_cast // The Operations implicitly executed by the compiler can be displayed by static_cast. The displayed forced type conversion generates a warning, when static_cast is used, the warning is disabled. // static_cast is the basic type conversion. Double dnum = 12.2356; void * PTR = & dnum; // double * dp = static_cast <double *> (PTR); // This is the c ++ standard format double * dp = (double *) PTR; // forced conversion in C language, with the same effect as the previous sentence // 3.r Einterpret_cast I want to see what this is. // re-Explain it based on the binary bit to see if it makes no sense. // 4. dynamic_cast has time to look at getchar (); Return 0;} // the example of a difference between static_cast and reinterpret_cast is to map to a completely different type, this keyword is used when we need to map the type back to the original type. The type we map to is only for xuanjicang and other purposes, which is the most dangerous of all mappings. (This is the original statement in the C ++ programming philosophy) the difference between static_cast and reinterpret_cast lies in multiple inheritance, such as class A {public: int M_a;}; Class B {public: int m_ B ;}; Class C: Public A, public B {}; then for the following code: C; printf ("% P, % P, % P", & C, reinterpret_cast <B *> (& C), static_cast <B *> (& C); the first two output values are the same, the last one offsets four bytes from the original base. This is because static_cast calculates the offset of parent-child pointer conversion and converts it to the correct address (M_a, m_ B, convert to B * pointer and then point to m_ B), but reinterpret_cast does not perform this conversion. Therefore, use reinterpret_cast with caution.