Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect use of string::size_type in ex3_17.cpp #796

Open
MonsieurNeko opened this issue Feb 13, 2021 · 0 comments
Open

Incorrect use of string::size_type in ex3_17.cpp #796

MonsieurNeko opened this issue Feb 13, 2021 · 0 comments

Comments

@MonsieurNeko
Copy link

In the last for loop, the loop variable has semantically no reason to be a string::size_type as we iterate a vector and not a string.

It would be better to write, for consistency with examples from the book, something like this:

for (decltype(vec.size()) i = 0; i != vec.size(); ++i)
{
    if (i != 0 && i % 8 == 0) cout << endl;
    cout << vec[i] << " ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant