1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
// Example program
#include <iostream>
#include <vector>
#include <utility> // std::pair
int main()
{
using std::vector;
using std::pair;
// initialize with two elements in the vector
vector<pair<int, pair<int, int>>> a = {
pair<int, pair<int, int>>(3, pair<int, int>(4, 5)),
pair<int, pair<int, int>>(6, pair<int, int>(7, 8)),
};
// push_back another element
a.push_back( pair<int, pair<int, int>>(9, pair<int, int>(10, 11)) );
// alternatively,
vector<pair<int, pair<int, int>>> b = {
{3, {4, 5}},
{6, {7, 8}},
{9, {10, 11}}
};
}
|