1 #include <iostream> 2 using namespace std; 3 4 template <class T> 5 void show(T *p) 6 { 7 //初始化 8 decltype(*p) num(*p); 9 cout << *p << endl; 10 } 11 12 void main() 13 { 14 auto man("2134"); 15 cout << typeid(man).name() << " " << man << endl; 16 auto man2(man); 17 cout << typeid(man2).name() << " " << man << endl; 18 19 //获取变量类型,创建类型或指针,并初始化 20 decltype(man) man3[2]{ man,man }; 21 for (auto i : man3) 22 { 23 cout << typeid(i).name() << " " << i << endl; 24 } 25 26 int num = 10; 27 show(&num); 28 cin.get(); 29 }