-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
crcrcry
committed
Sep 5, 2017
1 parent
6ed45ad
commit b5bd9e0
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# 一、变量和基本类型 | ||
## 1.1 基本内置类型 | ||
### 1.1.1 切勿混用带符号类型和无符号类型 | ||
- unsigned int u = 0 - 1,在 int 32 位机器上,得到的结果是 u = 4294967295; | ||
- 因为 -1 在机器上补码为 111...1,而 unsigned int 会将此理解为无符号位。 | ||
- 当带符号和无符号混用时,带符号类型会自动转化为无符号类型。所以若带符号类型为负数,则会产生异常结果。 | ||
|
||
### 1.1.2 通过添加前缀或后缀,改变字面量默认类型 | ||
|
||
## 1.2 变量 | ||
### 1.2.1 列表初始化 | ||
- 通过花括号进行初始化,叫列表初始化。 | ||
- 若使用列表初始化且初始值存在丢失信息的风险,编译器将报错。 | ||
|
||
### 1.2.2 声明和定义 | ||
- extern | ||
- 分离式编译 | ||
|
||
### 1.2.3 作用域操作符 | ||
- 嵌套作用域,内层同名覆盖。 | ||
- ::,用于访问作用域,如:std::cin。若左侧为空则代表请求全局作用域。 | ||
|
||
### 1.2.4 复合类型 | ||
- 例如:有引用和指针 | ||
- 引用即别名、而非对象,所以没有自己的地址空间。初始化时和变量完成绑定,类型需要严格匹配。 | ||
- 指针是对象,允许赋值和拷贝。类型也需要严格匹配。 | ||
- 空指针:nullptr 为空指针字面量。0 初始化指针也是一样的效果。NULL 最好需要 stdlib,值就是 0。 | ||
- void *。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters