模板例子

#include <iostream>
template<int bound, typename T>
void f1(T(&ary)[bound])
{
    T x;
    for (int i = 0; i < bound; i++)
    {
        x = ary[i];
        std::cout << x << std::endl;
    }
}

int main()
{
    int a[] = { 1, 2, 3, 4, 5, 6 };
    f1(a);
    return 0;
}

 

posted @ 2017-03-05 13:29  zzyoucan  阅读(121)  评论(0编辑  收藏  举报