1 #include <iostream> 2 using namespace std; 3 4 //模板自动匹配*多的 5 template <class T> 6 void com(T *p) 7 { 8 cout << "*" << endl; 9 cout << typeid(T).name() << endl; 10 } 11 12 template <class T> 13 void com(T **p) 14 { 15 cout << "**" << endl; 16 cout << typeid(T).name() << endl; 17 } 18 19 20 void main() 21 { 22 int *p = nullptr; 23 int **pp = nullptr; 24 int ***ppp = nullptr; 25 com(p); 26 com(pp); 27 com(ppp); 28 29 cin.get(); 30 }