Summary of some programming language aspects of the OJ exercise

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.