C + + provides 4 type-to operators, namely: Static_cast, dynamic_cast, reinterpret_cast, and const_cast;
The syntax format is as follows:
Type conversion Operators < type_id> (expreession);
Description: TYPE_ID is the target type; expression is the original data.
1. dynamic_cast: It is mainly used for upstream conversion and downlink conversion between class hierarchies. The dynamic_cast and static_cast effects are the same when you move up and down the class hierarchy: When you run a downstream conversion, dynamic_cast has type checking, which is more secure than static_cast (dynamic_ The cast operator also requires the support of the virtual mechanism).
2, reinterpret_cast: You can convert the value of shaping to an address. The C + + compiler believes that programmers are well aware of the consequences of such coercion, and therefore it is reasonable to take the unpredictable consequences that it brings to the programmer.
3. The Const_cast:const_cast conversion is a const or volatile qualifier used to remove a variable.
C + + type conversion operators