[function / bind] How to register callbacks using boost::function/bind?

Hi all,
I am trying to use a callback mechanism for logging in my app. I thus have
a class with :
class coordinates_converter
{
public:
coordinates_converter(int id);
~coordinates_converter();
void register_error_callback (const
boost::function

The problem is here: converter->register_error_callback( boost::bind(&another_class::log_error, converter, _1) ); The second parameter to bind should be an instance of the class whose member function you're trying to bind to: It should rather be converter->register_error_callback( boost::bind(&another_class::log_error, *another_class_instance*, _1) ); Under the hood, what will be happening is boost::function will call *another_class_instance->log_error(...)* * * If you think about it, you can't call converter->log_error, since coordinates_converter::log_error doesn't exist.
participants (2)
-
Olivier Tournaire
-
Steve Lorimer