Why do I need to dereference iterators?
问题 Why do I need to dereference iterators? For example in the following program #include <iostream> #include <string> #include <vector> int main() { using namespace std; string s("some string"); for(auto it = s.begin(); it != s.end(); && !isspace(*it); ++it) *it = isupper(*it); cout<<s; } Why is it necessary to use isupper(*it); instead of just isupper(it); ? 回答1: Iterator is a generalized pointer. It points to something. If you have a function that needs that something(char or int, in this case