1234567891011121314
std::vector<std::string> v1; v1.push_back("bbbb"); v1.push_back("cccc"); for(std::vector<std::string>::iterator iter = v1.begin(); iter != v1.end(); ++iter) { std::string word = *iter; word[0] = 'A'; std::cout << word << std::endl; } for(std::vector<std::string>::iterator iter = v1.begin(); iter != v1.end(); ++iter) { std::string word = *iter; std::cout << word << std::endl; }
123
std::string* word = &(*iter); (*word)[0] = 'A'; std::cout << *word << std::endl;
word
(*iter)[0] = 'A'; iter->at(3) = 'Z'; std::cout << *iter << std::endl;
std::string& word = *iter;