我有这个非常简单的 C++ 类:
class Tree {
public:
Node *head;
};
BOOST_PYTHON_MODULE(myModule)
{
class_<Tree>("Tree")
.def_readwrite("head",&Tree::head)
;
}
我想从 Python 访问 head 变量,但我看到的消息是:
No to_python (by-value) converter found for C++ type: Node*
据我了解,发生这种情况是因为 Python 吓坏了,因为它没有指针的概念。如何从 Python 访问 head 变量?
我知道我应该使用封装,但我目前坚持需要非封装解决方案。