Q:

What is wrong with the following program? How might you correct it

0

What is wrong with the following program? How might you correct it?

list<int> lst1;
list<int>::iterator iter1 = lst1.begin(),
 iter2 = lst1.end();
while (iter1 < iter2) /* ... */

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

The iterator of `list` does not support iterator arithmetic, including relational operators like `>`, `<`. Thus the condition for the `while loop` should be `iter1 != iter2`.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now