数据类型指定变量可以存储的数据类型,例如整数,浮点数,字符等。
C++语言中有4种数据类型。
链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-data-types.html
来源:LearnFk无涯教程网
类型 | 数据类型 |
---|---|
基本数据类型 | int,char,float,double等 |
派生数据类型 | 数组(array),指针(pointer)等 |
枚举数据类型 | 枚举(enum) |
用户定义的数据类型 | 结构(structure) |
基本数据类型是基于整数和基于浮点的。 C++语言支持有符号和无符号文字。
基本数据类型的内存大小可能会根据32或64位操作系统而变化。
让我们看一下基本数据类型。它的大小是根据32位操作系统给出的。
数据类型 | 内存大小 | 范围 |
---|---|---|
char | 1个字节 | -128至127 |
signed char | 1个字节 | -128至127 |
unsigned char | 1个字节 | 0到127 |
short | 2字节 | -32,768至32,767 |
signed short | 2字节 | -32,768至32,767 |
unsigned short | 2字节 | 0到32,767 |
int | 2字节 | -32,768至32,767 |
signed int | 2字节 | -32,768至32,767 |
unsigned int | 2字节 | 0到32,767 |
short int | 2字节 | -32,768至32,767 |
signed short int | 2字节 | -32,768至32,767 |
unsigned short int | 2字节 | 0到32,767 |
long int | 4字节 | |
signed long int | 4字节 | |
unsigned long int | 4字节 | |
float | 4字节 | |
double | 8字节 | |
long double | 10字节 |
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)