【发布时间】:2013-09-17 09:02:43
【问题描述】:
我想实现和使用一些类Base。在 Python 中是这样的:
class Base:
def Enumerate(self):
d = []
for attr in dir(self):
if not attr.startswith('__') and not callable(getattr(self, attr)):
d.append(attr)
return d
class One(Base):
hello = "world"
class Two(Base):
foo = "bar"
arr = [One(), Two()]
arr[0].Enumerate()
arr[1].Enumerate()
但我想使用boost::python 在 C++ 中实现Base 类。
我用谷歌搜索了很多,但没有找到任何东西。看起来与boost::python::wrapper 相关。
有人能告诉我怎么做吗?
【问题讨论】:
-
首先你可以在这里看到docs using inheritance
标签: c++ python boost python-2.7 boost-python