标签:
多元数组,数据类型可以不一样
1 #include <iostream> 2 #include <map> 3 using namespace std; 4 5 void main() 6 { 7 int int1(10); 8 double double1(99.8); 9 char ch1(‘a‘); 10 char *str = "hellochina"; 11 12 //tuple必须是静态数组 13 //配合array,vector使用 14 tuple<int, double, char, const char *>mytuple(int1, double1, ch1, str); 15 16 auto data0 = get<0>(mytuple);//下标只能是常量 17 auto data1 = get<1>(mytuple); 18 auto data2 = get<2>(mytuple); 19 auto data3 = get<3>(mytuple); 20 21 cout << typeid(data0).name() << " " << data0 << endl;//打印数据类型 22 cout << typeid(data1).name() << " " << data1 << endl; 23 cout << typeid(data2).name() << " " << data2 << endl; 24 cout << typeid(data3).name() << " " << data3 << endl; 25 26 decltype(data0) dataA;//获取数据类型再次创建 27 28 system("pause"); 29 }
标签:
原文地址:http://www.cnblogs.com/denggelin/p/5615649.html