这个明白了,不过我想问的不是这个问题。
#include <iostream>
using namespace std;
template <class T,int NN>
void xym (T (&a)[NN])
{
int a=99;
cout<<NN<<", "<<a<<endl;
//return 0;
}
int main(int xymc,char* xymv)
{
char b[22];
xym(b);
return 0;
}
/*我是因为这个没通过,所以才改成那种简单的,我是在看primer c++533页。
--------------------Configuration: template - Win32 Debug--------------------
Compiling...
template.cpp
D:\code\vc\cprogram\template\template.cpp(4) : error C2265: '<Unknown>' : reference to a zero-sized array is illegal
D:\code\vc\cprogram\template\template.cpp(13) : error C2784: 'void __cdecl xym(T (&)[1])' : could not deduce template argument for ' (&)[1]' from 'char [22]'
执行 cl.exe 时出错. template.exe - 1 error(s), 0 warning(s)
*/