#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
class BASE
{
public:
int fun1(int i){return i * 1;}
};
int main(){
int (BASE::*pf2)(int);
boost::shared_ptr<BASE> pB = boost::make_shared<BASE>();
pf2 = &BASE::fun1;
std::cout << (pB->*pf2)(3) << std::endl; // compile wrong: error: no match for 'operator->*' in 'pB ->* pf2'|
}
这是否意味着Boost库没有实现 "->*" 操作符来支持使用它来调用成员函数指针?
BASE
没有定义成员变量pf2
。你是不是想说fun2
? - Rafał Rawickipf2
的定义 -- 我猜它是指向BASE
类的成员函数的指针? - interjay