Function return pointer to another type of function - C++ -
bool (__fastcall fun)(float par1, float par2) { return (par1 == par2) ? true : false; } bool (__fastcall *newfun())(std::string str) { //... return fun; }
i have error: error return value type not match function type.
what wrong?
will help:
bool (__fastcall fun)(float par1, float par2) { return (par1 == par2) ? true : false; } bool (__fastcall *newfun(std::string str))(float par1, float par2) { //... return fun; } int main() { auto p = newfun("somestring"); cout << p(1.0, 1.0) << endl; cout << p(1.0, 1.1) << endl; return 0; }
maybe want read how function pointers in c work?
i think quite discussion of function pointers.
Comments
Post a Comment