12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
#include <iostream> #include <string> #include <vector> using namespace std; int main(){ vector<string> vList; vList.push_back("a"); vList.push_back("b"); vList.push_back("c"); vList.push_back(":"); vList.push_back(":"); vList.push_back(":"); vList.push_back("d"); std::string sswicher, str2; char lastChar1, lastChar2; bool blok1 = false; for(auto it = vList.begin(); it != vList.end(); it++) { if(blok1 == false){ sswicher = (*it); lastChar1 = *sswicher.rbegin(); } blok1 = false; it++; sswicher = (*it); lastChar2 = *sswicher.rbegin(); if((lastChar1 == ':') && (lastChar2 == ':')) { it-=1; delete (*it); //Expression has to be a pointer <-- What should I do now? (*it) = nullptr; it = vList.erase(it); lastChar1 = lastChar2; blok1 = true; } } for(auto it = vList.begin(); it != vList.end(); it++) { cout << (*it) << endl; } getchar(); return 0; }
auto
it
std::vector<std::string>::iterator
*it
std::string