Specify an inline callback function as an argument.

Posted by Matthias Vance on Stack Overflow See other posts from Stack Overflow or by Matthias Vance
Published on 2010-05-08T23:18:12Z Indexed on 2010/05/08 23:48 UTC
Read the original article Hit count: 254

Filed under:
|
|
|
|

LS,

Let me first explain what I'm trying to achieve using some pseudo-code (JavaScript).

// Declare our function that takes a callback as as an argument, and calls the callback with true.
B(func) { func(true); }

// Call the function
B(function(bool success) { /* code that uses success */ });

I hope this says it all. If not, please comment on my question so I can write a little more to clarify my issue.

What I want is to have code like this in C++.

I have tried to use lambda functions, but I was unable to specify a parameter type for those.

Kind regards,

Matthias Vance

© Stack Overflow or respective owner

Related posts about c++

Related posts about callback