make_pair を使ってみる (C++)
C++
Published: 2019-10-02

やったこと

make_pair を使ってみます。

確認環境

$ g++ --version
g++ (Homebrew GCC 9.2.0) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

調査

test.cpp

#include <bits/stdc++.h>
using namespace std;

int main() {
    pair<int, int> p[10];
    p[0] = make_pair(1, 100);
    p[1] = make_pair(2, 333);

    for (int i = 0; i < 2; i++) {
        printf("first: %d second: %d\n", p[i].first, p[i].second);
    }
}

出力結果

first: 1 second: 100
first: 2 second: 333

参考