# Include
# Include // Contains Vector
Using namespace STD; // specify the namespace
Int main ()
{
Cout
//////////////////////////////////////// /////
// Define a vector
//////////////////////////////////////// /////
Vector Vect;
Vector Vect1 (12); // 12 INT-type elements. The initial values of each element are 0.
Vector Vect2 (); // 12 INT values. The initial value is 9.
//////////////////////////////////////// /////
// Use an array to initialize the Vector
//////////////////////////////////////// /////
Int A [] = {, 0 };
// Vector (,). Element 1, 2, 3 in VT execution
Vector Vt (a + 1, A + 4 );
// Press 3 values at the end
Vt. push_back (1 );
Vt. push_back (2 );
Vt. push_back (3 );
// Define the iterator
Vector : Iterator iter = vt. Begin (); // start address
Vector : Iterator iter_end = vt. End (); // end address. Both addresses are pointer types.
// Traverse vt
For (; iter! = Iter_end; ITER ++)
{
Cout}
//////////////////////////////////////// ///////
// An element is displayed.
//////////////////////////////////////// ///////
Vt. pop_back (); // execution pop-up
// Obtain the start and end addresses in the following two rows
Iter = vt. Begin ();
Iter_end = vt. End ();
Cout for (; iter! = Iter_end; ITER ++)
{
Cout}
//////////////////////////////////////// ////////
// Insert element
//////////////////////////////////////// ////////
Cout // insert format: vector. insert (,); if the number of inserts is 1, the second parameter can be omitted.
Vt. insert (vt. Begin () + 1, 3, 9 );
Iter = vt. Begin ();
Iter_end = vt. End ();
For (; iter! = Iter_end; ITER ++)
{
Cout}
//////////////////////////////////////// ////////
// Delete an element
//////////////////////////////////////// ///////
Cout // Delete format 1: vector. Erase ();
// Deletion Format 2: vector. Erase (,);
Iter = vt. Begin ();
Iter_end = vt. End ();
Vt. Erase (ITER + 1, iter_end); // Delete the second to the last element.
Iter_end = vt. End ();
For (; iter! = Iter_end; ITER ++)
{
Cout}
Return 1;
}