template问题,大家帮忙看看!在线等
源代码如下
#include "stdafx.h"
#include <iostream>
using namespace std;
template<class type,int size> type min(const type (&array)[size])
{
cout<<"test ok size="<<size<<endl;
return 0;
}
int main(int argc, char* argv[])
{
int a[5]={1,2,3,4,5};
int i=min(a);
return 0;
}
为什么编译说reference to a zero-sized array is illegal
size我应该是template实力化的时候才传的啊,迷惑中.......