Let's say that I've got a :
#include <utility>
using namespace std;
typedef pair<int, int> my_pair;
how do I initialize a const my_pair ?
使用它的构造函数:
const my_pair p( 1, 2 );
With C++11 you can also use one of the following:
const my_pair p = {2, 3};
const my_pair p({2, 3});
const my_pair p{2, 3};
const my_pair p = std::make_pair( 2, 3);
const my_pair p = my_pair(3,2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.