C++有没有像std :: pair但有3个元素的东西?
例如:
#include <triple.h>
triple<int, int, int> array[10];
array[1].first = 1;
array[1].second = 2;
array[1].third = 3;
Run Code Online (Sandbox Code Playgroud)
jua*_*nza 30
您可能正在寻找std::tuple:
#include <tuple>
....
std::tuple<int, int, int> tpl;
std::get<0>(tpl) = 1;
std::get<1>(tpl) = 2;
std::get<2>(tpl) = 3;
Run Code Online (Sandbox Code Playgroud)
4pi*_*ie0 10
类模板std::tuple是异构值的固定大小集合,自C++ 11以来可在标准库中使用.它是std::pair标题的概括和表示
#include <tuple>
Run Code Online (Sandbox Code Playgroud)
你可以在这里阅读:
http://en.cppreference.com/w/cpp/utility/tuple
例:
#include <tuple>
std::tuple<int, int, int> three;
std::get<0>( three) = 0;
std::get<1>( three) = 1;
std::get<2>( three) = 2;
Run Code Online (Sandbox Code Playgroud)