c++ - 3.9.1 基本类型

标签 c++

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 实际上是一个整型。只是类型也用于表示字符。既然是整数类型,那么谈符号性是有道理的。

(具体历史原因我也不清楚,可能是bytechar混用,省去了关键字)

关于c++ - 3.9.1 基本类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3618419/

相关文章:

c++ - 函数未声明(首次使用此函数)

c++ - adjacent_difference 与 pre 和 next 一起工作

c++ - 从函数返回指向二维数组的指针 - C++

c++ - 允许共享库中 undefined reference 的 g++ 标志是什么?

c++ - 在 QmessageBox 中显示图像

c++ - 如何将链表对象写入文件

c++ - 我可以持有 std::list 的新插入元素的迭代器并使用迭代器稍后安全地删除该元素吗?

c++ - 如何从 GLSL 程序中获取 uvec4 输出

c++ - 删除指向 vector 的指针

c++ - 在没有源代码的情况下使用 gdb 进行调试