50.模板嵌套

 1 #include <iostream>
 2 #include <vector>
 3 #include <list>
 4 using namespace std;
 5 
 6 //传递模板进去自动确定模板的元素类型
 7 template<class T,class T2>
 8 void showall(vector<T> v,list<T2> l)
 9 {
10     for (auto i : v)
11     {
12         cout << i << endl;
13     }
14     for (auto i : l)
15     {
16         cout << i << endl;
17     }
18 }
19 
20 void main()
21 {
22     vector<int> myint{ 1,2,3,4,5 };
23     list<char> mychar{ 'a','b','c' };
24     showall(myint,mychar);
25     cin.get();
26 }
原文地址:https://www.cnblogs.com/xiaochi/p/8552718.html