3
私はこの方法でテンプレートを使用しています。C++ typenameを使用して関数にtypedefを渡すテンプレート
#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;
}
参照[「テンプレート内のポインタの配列の崩壊」]でデータ構造をラップ考える(http://stackoverflow.com/questions/1863751/array-decay-to-pointersイン・テンプレート)。タイプを保持するには、参照を使用する必要があります。 'int'を参照してください。' int'は 'insert_ord(T V []、int ll、int const LF、T&e)'です。 –