function のテンプレートを作成するように言われました。これには 4 つの引数が必要です。
- ポインタ
- 参照
- 配列へのポインタ
- 関数へのポインタ
このタスクの実行方法 やってみた :
#include <iostream>
using namespace std;
int nothing(int a)
{
return a;
}
template<typename T> T func(int *L, int &M, char *K, int (*P)(int))
{
cout << L << "," << M << "," << K[0] << "," << P() << endl;
return 0;
}
int main()
{
int x = 3;
int *z = &x;
int &y = x;
char c[3];
int (*pf)(int) = nothing;
cout << "some result of func" << func(z, y, c, pf) << endl;
system("pause");
return 0;
}
これにより、「一致する関数がありません。「pf」の場合だと思います。また、pf内で何を渡すかを制御できないか、間違っていますか?