Item09. Forced conversion (New Cast Operators)

xiaoxiao2021-03-05  22

Item09. New Cast Operators

Const_cast: Go to the Const modifier to turn the const variable to a non-constant_cast_cast: Forced conversion between different types (TYPE) variables Dynamic_cast: In the inheritance hierarchy, turn ReinterPret_cast: Free conversion.

--------------------------- 1, Static_cast Although it can be used to convert down type conversion, but still use Dynamic_CAST as good 2, ReinterPret_cast Strong, the most dangerous, and do not have to use it. 3, use these operators, make the program more clear ... Since C joins this four operators, there must be a basket of reasons, then use it!

转载请注明原文地址:https://www.9cbs.com/read-37545.html

New Post(0)