Skip to content

Commit

Permalink
修改一点小错
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphonse-xu committed Apr 5, 2020
1 parent 2248b35 commit 0af560c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions notes/ch03.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
| `string s3 = "value"` | 等价于`s3("value")``s3`是字面值"value"的副本 |
| `string s4(n, 'c')` |`s4`初始化为由连续`n`个字符`c`组成的串 |

- 拷贝初始化(copy initialization):使用等号`=`初始化一个变量
- 直接初始化(direct initialization):不使用等号
- 拷贝初始化(copy initialization):使用等号`=`将一个已有的对象拷贝到正在创建的对象
- 直接初始化(direct initialization):通过括号给对象赋值。

### string对象上的操作

Expand All @@ -36,7 +36,7 @@
| `getline(is, s)` |`is`中读取一行赋给`s`,返回`is` |
| `s.empty()` | `s`为空返回`true`,否则返回`false` |
| `s.size()` | 返回`s`中字符的个数 |
| `s[n]` | 返回`s`中第`n`个字符的医用,位置`n`从0计起 |
| `s[n]` | 返回`s`中第`n`个字符的引用,位置`n`从0计起 |
| `s1+s2` | 返回`s1``s2`连接后的结果 |
| `s1=s2` |`s2`的副本代替`s1`中原来的字符 |
| `s1==s2` | 如果`s1``s2`中所含的字符完全一样,则它们相等;`string`对象的相等性判断对字母的大小写敏感 |
Expand Down Expand Up @@ -135,7 +135,7 @@
- **迭代器(iterator)**:每种标准容器都有自己的迭代器。`C++`倾向于用迭代器而不是下标遍历元素。
- **const_iterator**:只能读取容器内元素不能改变。
- **箭头运算符**: 解引用 + 成员访问,`it->mem`等价于 `(*it).mem`
- **谨记**单反是使用了迭代器的循环体,都不要向迭代器所属的容器添加元素。
- **谨记**但凡是使用了迭代器的循环体,都不要向迭代器所属的容器添加元素。

标准容器迭代器的运算符:

Expand Down

0 comments on commit 0af560c

Please sign in to comment.