C++11: Practical Features

Source: Internet
Author: User

Today stroll cplusplus.com found that C + + is really a lot of easy to use features, first understand some of the most commonly used

Initialize List
    vector<int> tmp ({1,2,3,4});        Vector<pair<intint> > tmp_pair (        {            {12  },            {34}        }    );

or direct initialization, very much like the normal array initialization.

    vector<int> tmp = {1234};        Vector<pair<intint> > tmp_pair ={        12 },        {34}    };
For Iteration
     for (int  e:tmp) {        cout<<e<<endl;    }          for (pair<intint>& e:tmp_pair) {        cout<<e.first<<"  ,"<<e.second<<Endl;    }

This is like Java, which is much easier than writing explicit iterators, especially in C + + where iterator declarations are too cumbersome (as if you can use auto to automatically determine the type)

C++11: Practical Features

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.