Hello,
I have a while loop, and in it, I allocates a new class called TokenItem. It is then pushed into a vector. Question: When is the TokenItem deallocated? Do I have to explicitly delete it?
Code:
while (string::npos != pos || string::npos != lastPos) { // Found a token, add it to the vector.
char tokenStateInsert;
if (tokenState==TOKEN_OFF)
tokenStateInsert=' ';
else tokenStateInsert= str.at(pos+1);
tokens.push_back( TokenItem(tokenStateInsert,
str.substr(lastPos, pos - lastPos))); // Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos); // Find next "non-delimiter"
pos = str.find_first_of(delimiters, lastPos);
} //while