What would happen if the while loop on page 148 that prints the elements from a vector used the prefix increment operator
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:4| Question number:4.18
All Answers
total answers (1)
The loop will print all elements except the first one in the vector, and also try to dereference to one past the last element, which is an error. Also, if there is no negative value in the vector, the loop will continue to dereference whatever in memeory until a negative value is found, which is a disaster.
need an explanation for this answer? contact us directly to get an explanation for this answer