Function add exists that takes 4 arguments. The first 3 arguments are references to const int, the fourth argument is bool. The function returns pointer for int.
Function make_add_to takes 3 arguments. First is a pointer to function with the same structure as Add function, the second argument is a reference to const int, third is bool. This function returns a pointer to a function that takes a reference to const int and returns pointer for int.
add_to is a pointer to function, which is returned from function make_add_to
Can anyone finish this? I'm not sure if make_add_to is correct though
#include <iostream>
using namespace std;
int * add(const int &x1, const int &x2, const int &x3, bool y);
int * (*make_add_to(const int &x5))(int *(*f)(const int &x1, const int &x2, const int &x3, bool y),const int &x4, bool y);
int main()
{
int x=3,y=2,z=1;
//cout << *dodaj(x,y,z,true);
int *(*ptr)(const int &x1, const int &x2, const int &x3, bool y) = &add;
//cout << *ptr(x,y,z,true);
// (*dodaj_do)
}
int * add(const int &x1, const int &x2, const int &x3, bool y)
{
int * re = new int;
int x = x1+x2+x3;
re = &x;
return re;
}