Skip to content

Commit 49f218e

Browse files
committed
增加 const 的指针与引用
#12 (comment)
1 parent 2dd3a8b commit 49f218e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@
5454
3. 修饰引用,指向常量的引用(reference to const),用于形参类型,即避免了拷贝,又避免了函数对值的修改;
5555
4. 修饰成员函数,说明该成员函数内不能修改成员变量。
5656

57+
#### const 的指针与引用
58+
59+
* 指针
60+
* 指向常量的指针(pointer to const)
61+
* 自身是常量的指针(常量指针,const pointer)
62+
* 引用
63+
* 指向常量的引用(reference to const)
64+
* 没有 const reference,因为引用本身就是 const pointer
65+
5766
> (为了方便记忆可以想成)被 const 修饰(在 const 后面)的值不可改变,如下文使用例子中的 `p2``p3`
5867
5968
#### 使用

docs/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
3. 修饰引用,指向常量的引用(reference to const),用于形参类型,即避免了拷贝,又避免了函数对值的修改;
1717
4. 修饰成员函数,说明该成员函数内不能修改成员变量。
1818

19+
#### const 的指针与引用
20+
21+
* 指针
22+
* 指向常量的指针(pointer to const)
23+
* 自身是常量的指针(常量指针,const pointer)
24+
* 引用
25+
* 指向常量的引用(reference to const)
26+
* 没有 const reference,因为引用本身就是 const pointer
27+
1928
> (为了方便记忆可以想成)被 const 修饰(在 const 后面)的值不可改变,如下文使用例子中的 `p2``p3`
2029
2130
#### 使用

0 commit comments

Comments
 (0)