How to pass a value in a return function as an argument on another function, use it in and then call it appropriately C++? -


i know how pass return function function argument can use value.

example:

int childfunction(int a, int b) {     int c;     c = + b;     return c; }  void motherfunction(int d, int (childfunction)(int a, int b)) {     //some operation example } 

thank you

pointer function

use * make pointer function:

void motherfunction(int d, int (*f)(int, int)) {     int y = f(1, 2); } ...  motherfunction(100, childfunction); 

 

std::function1

void motherfunction(int d, const std::function<int(int,int)> &f) {     int y = f(1, 2); } ...  motherfunction(100, childfunction); 

 

template based

template <typename f> void motherfunction(int d, const f &f) {     int y = f(1, 2); } ...  motherfunction(100, childfunction); 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -