这个模板调用为什么失败,书上讲的没看懂
#include<iostream>using namespace std;#include<windows.h>#include<locale.h>template<typename T>T fref(const T&, const T&){}void main(){ setlocale (LC_ALL,"chs"); int a[10], b[42]; fref(a,b);}
int* fref(int*, int*){}//如果是这样就可以
[解决办法]
LZ注意哦,你用的是引用~
template<typename T>
T fref(const T&, const T&)
{
}
引用的话a[10], b[42];是两种不同的类型
用指针吧
template<typename T>
T fref(const T*, const T*)
{
}