In the previous section we gave a contrived example, where the condition in the for loop polled for data:
for (; poll_data() ;) { int i = get_data(); std::cout << i << std::endl; }
In this example, there is no loop variable used in the condition. This is a candidate for the while conditional loop:
while (poll_data()) { int i = get_data(); std::cout << i << std::endl; }
The statement will continue to loop until the expression (poll_data in this case) has a value of false. As with for, you can exit the while loop with break, return, throw, or goto, and you can indicate that the next loop should be executed using the continue statement.
The first time the while statement is called, the condition is tested before the ...