Adding to a vector of pair

后端 未结 10 1432
悲哀的现实
悲哀的现实 2021-01-30 05:19

I have a vector of pair like such:

vector> revenue;

I want to add a string and a doub

10条回答
  •  长情又很酷
    2021-01-30 05:46

    As many people suggested, you could use std::make_pair.

    But I would like to point out another method of doing the same:

    revenue.push_back({"string",map[i].second});
    

    push_back() accepts a single parameter, so you could use "{}" to achieve this!

提交回复
热议问题