【发布时间】:2017-02-18 10:45:22
【问题描述】:
我正在以这种方式使用模板。
#define MAX_CARS 999
typedef char plate[20];
template <typename T>
int insert_ord (T V[], int ll, int const LF, T e);
它可以工作,但是当我将 typedef 作为参数传递时,它说:没有匹配函数调用“insert_ord”。
这是主要的。
int main (void)
{
plate targhe[MAX_CARS];
int ll = 0;
plate targa;
cin >> targa;
ll = insert_ord(targhe, ll, MAX_CARS, targa);
cout << endl;
system("pause");
return 0;
}
【问题讨论】:
-
见"Array decay to pointers in templates"。您应该使用引用来保留类型。尝试
int insert_ord (T V[], int ll, int const LF, T &e),其中e是参考。
标签: c++ templates typedef typename