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 ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…