C++基础(二)基本数据类型

基本内置类型

算术类型

类型 含义 最小尺寸
bool 布尔 未定义
char 字符 8位
short 短整型 16位
int 整型 16位
long 长整型 32位
long long 长整型 64位
float 单精度浮点数 6位有效数字
double 双精度浮点数 10位有效数字
long double 扩展精度浮点数 10位有效数字

类型转换

  1. 当一个算术表达式中既有无符号数又有int值时,int会被转换为无符号数
  2. 当从无符号数中减去一个值时,不管这个值是不是无符号数,都必须保证结果不为负(否则为取模后值)

变量

变量声明于定义的关系

变量声明(declaration)定义了变量的类型和名字,定义(definition)在声明外还申请存储空间

如果只想声明,可在变量名前添加关键字extern

变量只能被定义一次,但是可以多次声明

作者

Martin

发布于

2023-05-26

更新于

2023-05-26

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.

You need to set client_id and slot_id to show this AD unit. Please set it in _config.yml.