forked from hunterzhao/EasySTL
-
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
1 parent
49aac49
commit 6dee4cd
Showing
4 changed files
with
42 additions
and
9 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,15 @@ | ||
error1: | ||
passing 'const EasySTL::vector<std::basic_string<char>, EasySTL::alloc>' as 'this' | ||
argument of 'T* EasySTL::vector<T, Alloc>::end() | ||
[with | ||
T = std::basic_string<char>; | ||
Alloc = EasySTL::alloc; | ||
EasySTL::vector<T, Alloc>::iterator = std::basic_string<char>*]' | ||
discards qualifiers [-fpermissive] | ||
size_type size() const { return size_type(end() - begin());} | ||
|
||
|
||
answer: | ||
const对象只能调用const成员函数;在一个加了const限定符的成员函数中,不能够调用 非const成员函数。 | ||
因为如果调用了非const成员函数,就违反了const成员函数不改变对象的规定。 | ||
所以为begin() end() 函数添加const |
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
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
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