June 2025
Intermediate to advanced
1093 pages
33h 24m
English
It would be even easier if you didn't have to look up exactly what begin() returns. The exact type doesn't really matter to you in this case. You define a variable it with the type and insert it into other functions. Someone who knows exactly what type begin() returns could actually help you and save you the trouble—and that someone is the compiler.
Suppose the compiler encounters something that looks like this:
vector<int> data{};? it = data.begin();
Then instead of ?, there really isn't much that can stand there. A look at the definition of vector::begin() shows that it can only be one of these two options:
vector<int>::iterator
vector<int>::const_iterator
It's even easier in the case of size():
Read now
Unlock full access