模板的嵌套指的是模板里面嵌套数据类型如vector和list等

//
// Created by Administrator on 2021/7/17.
//
#include<iostream>
#include<vector>
#include<list>
using namespace std;



template<class T1, class T2>
void showwall(vector<T1>(v), list<T2>l) //模板嵌套
{
    for(auto i : v)
    {
        cout << i << endl;
    }

    for(auto i : l)
    {
        cout << i << endl;
    }
}

int main()
{
    vector<int> myint1{1, 2, 3, 4, 5};
    vector<char> mych1{'a', 'b', 'c', 'd', 'e'};
    list<int> myint2{1, 2, 3, 4, 5};
    list<char> mych2{'a', 'b', 'c', 'd', 'e'};
    showwall(myint1, myint2);


}

 

posted on 2021-07-17 22:35  python我的最爱  阅读(170)  评论(0编辑  收藏  举报