1.STL Vector only four constructors
default(1) ExplicitVector (Constallocator_type& Alloc =Allocator_type ()); Fill (2) ExplicitVector (size_type N,Constvalue_type& val =value_type (),Constallocator_type& Alloc =Allocator_type ()); Range (3) Template<classInputiterator>Vector (inputiterator first, Inputiterator last,Constallocator_type& Alloc =Allocator_type ()); Copy (4) Vector (Constvector& x);
The first is the default constructor, and the parameter is the memory allocator.
The second is a fill type constructor with a Val value of n vector element type.
The third is the range's constructor, and the parameter is [First,last] left closed right open range.
The fourth one is the copy constructor, and the parameter is, of course, the const vector &.
The construction of a 2.STL two-dimensional array. such as vector<vector<int> > Vec;
There should be only the following methods:
Vector A1;a1.push_back (1); A1.push_back (2); A1.push_back (3 ); vector a2;a2.push_back (2); A2.push_back (3); A2.push_back (4 ); vec.push_back (A1); Vec.push_back (A2) ;
Therefore, initializing a two-dimensional array is cumbersome. It seems that there is no easier way to use a vector. At most, A1 and A2 are initialized with a range constructor, with parameters defined as array names and array names + lengths
Summary of some programming language aspects of the OJ exercise