Update item6.md

This commit is contained in:
猫耳堀川雷鼓 2021-03-02 12:00:01 +08:00 committed by GitHub
parent 577760c36d
commit caad38385d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,9 +9,9 @@ std::vector<bool> features(const Widget& w);
更进一步假设第5个*bit*表示`Widget`是否具有高优先级,我们可以写这样的代码:
````cpp
Widget w;
...
bool highPriority = features(w)[5]; //w高优先级吗
...
processWidget(w, highPriority); //根据它的优先级处理w
````
这个代码没有任何问题。它会正常工作,但是如果我们使用`auto`代替`highPriority`的显式指定类型做一些看起来很无害的改变:
@ -74,11 +74,11 @@ namespace std{ //来自于C++标准库
template<class Allocator>
class vector<bool, Allocator>{
public:
...
class reference { ... };
class reference { };
reference operator[](size_type n);
...
};
}
````