This question is related with item 16 of effective stl book which states that while using vector(lets assume vector<int>vec
) instead of array in a legacy code we must use &vec[0] instead of vec.begin() :
void doSomething(const int* pInts, size_t numlnts);
dosomething(&vec[0],vec.size()); \correct!!
dosomething(vec.begin(),vec.size()); \ wrong!! why???
The book states that vec.begin()
is not same as &vec[0]
. Why ? What the difference between the two ?