1
まあ、基本的に私はすべてのq &を参照して、私の答えを見つけることができません。別の関数の関数の関数
これは、正方形、立方体、四分の一の計算を行う私のコードです。しかし、答えを出力しようとするとエラーが発生します。
#include <iostream>
using namespace std;
int square (int); //n^2
int cube (int); //n^3
int fourth (int); //n^4
void powerN(int x[], const int sizex, void(*select)(int))
{
cout<< x[sizex];
cout<<" to the power of "<<sizex+2<<" is ";
cout<<(*select)(x[sizex])<<endl;
}
int square (int a)
{
return a*a;
}
int cube (int b)
{
return b*b*b;
}
int fourth (int c)
{
return c*c*c*c;
}
int main()
{
int a[3]={3,4,5};
for (int aSize=0;aSize<3;a++){
powerN (a, aSize, square);
powerN (a, aSize, cube);
powerN (a, aSize, fourth);
}
}
_But出力にanswer._をしようとし、エラーがあるときに、エラーがありますか?それは秘密ですか? –
同上、理由のためにエラーメッセージが存在します:エラーの原因を突き止めるのを手伝ってください!常に、常に、常に_あなたの質問にエラーメッセージを含めてください。 – qxz