模板例子

#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;
}
原文地址:https://www.cnblogs.com/zzyoucan/p/6505134.html