【发布时间】:2014-06-15 15:24:01
【问题描述】:
为什么以下内容无效?
bool trigger(t_evt evt) const {
std::shared_ptr<I> ptr = this->instance.lock();
if (!ptr) {
return false;
}
(ptr->*f)(evt); // -> causes a compilation error
return true;
}
英文的错误是这样的(我不明白英文):
'->*' : improper usage, left operand of type 'std::shared_ptr<ListenerCardsChange>'
f 是一个指向成员函数的指针。
请注意,(*ptr.*f)(evt); 工作正常。
【问题讨论】: