#include <iostream> int main(){ unsigned char a = 4,b = 255; int g = (unsigned char)a + (unsigned char)b; std::cout << g << std::endl; return 0; }
结果:
259
为什么结果是259,而不是3?如果添加了两个unsigned char变量,应该有溢出,结果应该是3,然后它应该从unsigned char 3转换为int 3.