typedef uint8_t RANGE;
int main()
{
const uint16_t FREQ_RATED_MIN_VALUE = 54;
RANGE* min;
min = (uint8_t*)&FREQ_RATED_MIN_VALUE; // C style tyecast
cout << min << endl; // prints value
min = reinterpret_cast<uint8_t*>(&FREQ_RATED_MIN_VALUE); //ERROR to be removed in this statement to be written in C++ style typecast
return 0;
}
需要帮助在声明中注释C ++样式的类型转换..
答案 0 :(得分:0)
您的演员会放弃const
资格。使用C ++样式转换来转换constness需要const_cast
。试试这个:
min = reinterpret_cast<uint8_t*>(const_cast<uint16_t*>(&FREQ_RATED_MIN_VALUE));