I want to replace an element into a specific position of a vector, can I just use an assignment:
// vec1 and 2 have the same length & filled in somehow
vec1;
vec2;
vec1[i] = vec2[i] // insert vec2[i] at position i of vec1
or I have to use insert():
vector<sometype>::iterator iterator = vec1.begin();
vec1.insert(iterator+(i+1), vec2[i]);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…