I believe the problem has something to do with the code below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void organizeList(std::vector<Contact> &c1) {
std::vector<Contact>::iterator iter = c1.begin();
std::vector<Contact> temp;
for(char a = 'A'; a <= 'Z'; ++a) {
for(iter; iter != c1.end(); ++iter) {
if((*iter).getLastC() == a)
temp.push_back(*iter);
}
}
while(!c1.empty())
c1.pop_back();
for(iter = temp.begin(); iter != temp.end(); ++iter)
c1.push_back(*iter);
}
The if statement's condition is not being met unless the lastName is equal 'A'. Why isn't it running through the for loop like it's supposed to? It's obviously something I did wrong.
void organizeList(std::vector<Contact> &c1) {
std::vector<Contact>::iterator iter = c1.begin();
std::vector<Contact> temp;
for(char a = 'A'; a <= 'Z'; ++a) {
for(iter; iter != c1.end(); ++iter) { // What value will iter have on the second iteration?if((*iter).getLastC() == a)
temp.push_back(*iter);
}
}
while(!c1.empty())
c1.pop_back();
for(iter = temp.begin(); iter != temp.end(); ++iter)
c1.push_back(*iter);
}