C++ 数据类型

数据类型指定变量可以存储的数据类型,例如整数、浮点数、字符等。

Cpp 数据类型 1

C++ 语言中有 4 种数据类型。

类型数据类型
基本数据类型int、char、float、double 等
派生数据类型array, pointer, etc
枚举数据类型enum
用户定义的数据类型structure

基本数据类型

基本数据类型是基于整数和基于浮点的。C++ 语言支持有符号和无符号文字。

基本数据类型的内存大小可能会根据 32 位或 64 位操作系统而变化。

让我们看看基本的数据类型。它的大小是根据 32 位操作系统给出的。

数据类型内存大小范围
char1 个字节-128 至 127
signed char1 个字节-128 至 127
unsigned char1 个字节0 至 127
short2字节-32,768 至 32,767
signed short2字节-32,768 至 32,767
unsigned short2字节0 至 32,767
int2字节-32,768 至 32,767
signed int2字节-32,768 至 32,767
unsigned int2字节0 至 32,767
short int2字节-32,768 至 32,767
signed short int2字节-32,768 至 32,767
unsigned short int2字节0 至 32,767
long int4字节
signed long int4字节
unsigned long int4字节
float4字节
double8字节
long double10 字节


上一主题 C++ 变量 下一主题 C++ 关键字
  • 使用社交账号登录,本站支持
全部评论(0)