File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -378,8 +378,8 @@ One of the most common and notable examples of type derivation using `auto` is t
378
378
``` cpp
379
379
// before C++11
380
380
// cbegin() returns vector<int>::const_iterator
381
- // and therefore itr is type vector<int>::const_iterator
382
- for (vector<int >::const_iterator it = vec.cbegin(); itr != vec.cend(); ++it)
381
+ // and therefore it is type vector<int>::const_iterator
382
+ for (vector<int >::const_iterator it = vec.cbegin(); it != vec.cend(); ++it)
383
383
```
384
384
385
385
When we have ` auto ` :
Original file line number Diff line number Diff line change @@ -314,8 +314,8 @@ C++11 引入了 `auto` 和 `decltype` 这两个关键字实现了类型推导,
314
314
``` cpp
315
315
// 在 C++11 之前
316
316
// 由于 cbegin() 将返回 vector<int>::const_iterator
317
- // 所以 itr 也应该是 vector<int>::const_iterator 类型
318
- for (vector<int >::const_iterator it = vec.cbegin(); itr != vec.cend(); ++it)
317
+ // 所以 it 也应该是 vector<int>::const_iterator 类型
318
+ for (vector<int >::const_iterator it = vec.cbegin(); it != vec.cend(); ++it)
319
319
```
320
320
321
321
而有了 ` auto ` 之后可以:
You can’t perform that action at this time.
0 commit comments