By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

Anonymous functions

P: n/a
Does C++ in some way support anonymous functions?

Say I have a callback function that I register
with SetCallback() (this perticular example
is from my attempts at messages, signals, events, etc
in a GUI for a game)

Would something in this way be possible:
(I know Java can do it...)

SetCallback (new function() = {
my_var++;
std::cout << "Hello!" << std::endl;
});
Thanks!

-- Pelle
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Pelle Beckman wrote:
Does C++ in some way support anonymous functions?
No.
Say I have a callback function that I register
with SetCallback() (this perticular example
is from my attempts at messages, signals, events, etc
in a GUI for a game)

Would something in this way be possible:
(I know Java can do it...)

SetCallback (new function() = {
my_var++;
std::cout << "Hello!" << std::endl;
});


No.

V
Jul 23 '05 #2

P: n/a

"Pelle Beckman" wrote:
SetCallback (new function() = {
my_var++;
std::cout << "Hello!" << std::endl;
});

Maybe Boost.Lambda libray could help you:
http://www.boost.org/doc/html/lambda.html

It requires fairly compatible compiler.

/Pavel
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.