there are 2 common ways to loop through a vector
1:
vector<int> myvec; // let's assume it's initialized
for(int i = 0; i != myvec.size( ); i++)
{
// code
// access by 'myvec[i]'
}
2:
vector<int> myvec; // let's assume it's initialized
for(vector<int> :: iterator i = myvec.begin( ); i != myvec.end( ); i++)
{
// code
// access by '*i'
}
what's the difference between the 2 methods, in what concerns me the first one is far more convenient since is cleaner and easier to use(no overhead with the '*', witch is also confusing sometimes, typically when u store pointers in your vector);
but in most of cases i've seen people using the second method. why?