C++ 四种强制转换类型函数
static_cast<new_type> (expression)
dynamic_cast<new_type> (expression)
const_cast<new_type> (expression)
reinterpret_cast<new_type> (expression)
const_cast
const_cast,用于修改类型的const属性。 该运算符用来修改类型的const(唯一有此能力的C+±style转型操作符)属性。
const int g = 20;
int *h = const_cast<int*>(&g);//去掉const常量const属性
const int g = 20;
int &h = const_cast<int &>(g