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

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -