我想用Python制作一个对象,使用SWIG来对C++实例进行一个SASTIFY。你知道吗
我举了一个类似Example.h
的例子:
struct iCat
{
virtual int paws() const = 0;
};
int pawGiver(const iCat& cat);
struct cat : public iCat
{
int paws() const
{
return 4;
}
};
和Example.cpp
:
#include "Example.h"
int pawGiver(const iCat& cat)
{
return cat.paws();
}
和example.i
:
/* File : example.i */
%module example
%{
#include "Example.h"
%}
%include "Example.h"
当然,以上这些都很好。我写下面这篇文章是为了用Python制作一个iCat
,即:
import example;
class pyCat(example.iCat):
def __init__(self):
super().__init__()
def paws(self):
return 3;
z = pyCat()
example.pawGiver(z)
我想做的事有可能吗?Python类能实现C++实例吗?我做错什么了?你知道吗
这很简单。将界面修改为:
运行良好。你知道吗
相关问题 更多 >
编程相关推荐