So I have been trying and battling with this for a few hours now. I am relatively new to c++ but I read about function pointers and it looked pretty useful. Essentially, what I am attempting to do below is to pass two integer values to the function foo and then multiply it by 10. However, I keep getting the following error: "invalid conversion from 'int' to 'int (*)(int, int)' [-fpermissive]".
#include <iostream>
using namespace std;
int foo(int nX, int nY){
return nX*nY;
}
int multTen(int a, int b, int (*Fn)(int, int)){
return 10*Fn(a,b);
}
int main(){
cout << multTen(3,4,foo(3,4)) << endl;
}
Your kind help in this regard is highly appreciated. :)