Hello everyone.. I am a little bit stuck on this small problem.
I'm trying to understand callbacks but seem to be no understanding something.
It is probably something very simple. I've never used callbacks so am probably misunderstanding something here.
The below is pointless but I'm doing it to improve my understanding of callback functions.
On the line indicated below, I get the error:
invalid conversion from 'int ()*(int, int)' to 'int' [-fpermissive]**
#include <iostream>
#include <cstdlib>
using namespace std;
int add(int a, int b)
{
return (a+b);
}
int multiply(int a, int(*x)(int t, int d))
{
int r = x; //error occurs here: invalid conversion from 'int (*)(int, int)' to 'int' [-fpermissive]
int e = a * r;
return e;
}
int main()
{
cout << "FUNCTION CALLBACKS" << endl;
cout << multiply(10,add(5,2)) << endl;
system("pause>null");
}