C++: variations on for loops