天天看點

C++标準庫tuple小例

#include <iostream>
#include <string>
#include <tuple>
using namespace std;

tuple<int,float,string> func(int a, float b,string s) {
	return make_tuple(a,b,s);
}

//輸出函數
void Print(tuple<int, float, string> t) {
		cout << get<0>(t) << " ";
		cout << get<1>(t) << " ";
		cout << get<2>(t) << " ";
		cout << endl;
}

int main() {
	tuple<int, float, string> t = func(1314, 520, "coolsunxu");
	auto t1= func(1314, 520, "coolsunxu");
	Print(t);
	Print(t1);
	system("pause");
	return 0;
}

           
C++标準庫tuple小例

繼續閱讀