我正在尝试使用boost python 用一个名为“addTwoNumbers”的函数来包装一个简单的演示类。这是头文件:
#ifndef DEMO_H_
#define DEMO_H_
#include <boost/function.hpp>
class Demo
{
public:
Demo() {}
virtual ~Demo() {}
typedef void (DemoCb) (int,int,int);
boost::function<DemoCb> onAddTwoNumbers;
int addTwoNumbers(int x, int y);
// Executes a callback within a thread not controlled by the caller.
void addTwoNumbersAsync(int x, int y, boost::function<DemoCb> callback);
};
#endif /* DEMO_H_ */
这是包装:
#include <boost/python.hpp>
#include "../demo.h"
using namespace boost::python;
// Create a python module using boost. The name 'demo' must match the name in the makefile
BOOST_PYTHON_MODULE(python_wrap_demo) {
// Wrapping the addTwoNumbers function:
class_<Demo>("Demo", init<>())
.def("addTwoNumbers", Demo::addTwoNumbers)
;
}
我让它适用于一个类似的功能,它没有包含在一个类中。为什么我现在收到此错误?