C++ 标准§3.9.1 基本类型
Objects declared as characters (char) shall be large enough to store any member of the implementation’s basic character set. If a character from this set is stored in a character object, the integral value of that character object is equal to the value of the single character literal form of that character. It is implementation-defined whether a char object can hold negative values. Characters can be explicitly declared unsigned or signed. Plain char, signed char, and unsigned char are three distinct types.<...>
我无法理解 unsigned char。
数字可以是 +1 或 -1。
我无法以类似的方式思考 -A 和 +A。
引入unsigned char的历史原因是什么。
最佳答案
char
实际上是一个整型。只是类型也用于表示字符。既然是整数类型,那么谈符号性是有道理的。
(具体历史原因我也不清楚,可能是byte
和char
混用,省去了关键字)
关于c++ - 3.9.1 基本类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3618419/