C ++ STL Vector Learning (Continued)

Header: <vector>

 

initialization

Vector <ElementType> VEC ( 10 ); / * ElementType data type 10 represents a single length of 10 * / 
Vector <ElementType> VEC ( 10 , 0 ); / * for all the elements 10 is given the initial value 0 * /

vector not like array as the use of braces assignment.

 

other

vec.push_back ( 5 ); / * is inserted after the last position of an element vec, a value of 5, the time efficiency is very high * / 

Reserve (vec.begin (), vec.end ()) / * array of inverted * /

 

 

Guess you like

Origin www.cnblogs.com/Eeyor/p/11240082.html