我有以下的情况,(在代码更好)C++成员函数的指针,升压::信号
class Foo
{
private:
typedef boost::signal<void()> Signal;
Signal signal;
public:
void Register_SignalFunction(const Signal::slot_type& slot);
void Unregister_SignalFunction(const Signal::slog_type& slot);
}
class OtherFoo
{
Foo foo;
public:
OtherFoo()
{
foo.Register_SignalFunction(&OnSignal) //I know I can't do this that is precisely my question.
}
void OnSignal(); //what to do when signal fires
}
所以,问题是,如何通过一个“成员函数”指针寄存器的方法。另外,这是好吗?我想/需要的是某种委托注册系统,所以如果任何人都无法指出我的方向,我会很感激。提前Thanx。
每当我尝试做一些类似foo我得到这个错误。Register_SignalFunction(boost :: bind(&OtherFoo :: OnSignal,this));错误C2678:二进制'==':找不到操作符找到类型为'const boost :: slot'的左手操作数是不可接受的转换)\t f:\ development \ boost_1_41_0 \ boost \ function_equal.hpp Indigen_Framework –
Yoss
@Yoss:我认为你的Signal typedef必须是公开的。除此之外,请发布一个最小的可编译示例。您当前的代码中存在拼写错误,例如Signal :: slog_type ... –