关于python 调用c++ 出现错误的问题
我有三个CPP文件
wrap.cpp
C/C++ code:
#include <Python.h>
#include "bridge.h"
extern "C"
{
PyObject* bridge(PyObject* self, PyObject* args)
{
int n = 0;
int result = 0;
if (! PyArg_ParseTuple(args, "answer", &n))
return NULL;
result = transport(4);
return Py_BuildValue("answer", result);
}
static PyMethodDef bridgeMethods[] =
{
{"transport", bridge, METH_VARARGS, "transport data"},
{NULL, NULL}
};
void initbridge()
{
PyObject* m;
m = Py_InitModule("bridge", bridgeMethods);
}
}
bridge.cpp
C/C++ code:
#include "bridge.h"
#include "faq.h"
extern "C"
{
int transport(int n)
{
FAQ *myFaq = new FAQ();
int c = myFaq->getBetterAnswer();
delete myFaq;
return c;
}
}
faq.cpp
C/C++ code:
#include "faq.h"
int FAQ::getBetterAnswer(void)
{
return 3;
}
void FAQ::printAnswer()
{
}
FAQ::FAQ()
{
}
FAQ::~FAQ()
{
}
使用 g
相关问答:
写了个测试程序如下
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
#include "stdio.h"
int main()
{
char *ch(char *, char *);
char str1[]="I am glad to meet you!";
char str2[]="Welcom to study C!";
&nb ......
#include "stdio.h"
void main()
{
int *p;
int a[10]={0,1,2,3,4,5,6,7,8,9};
int k=0;
p=a;
for(int i=0;i<10;i++,p ......
SHIFT加F10与那个键右ctrl边上的那个键功能一样,想屏这个
但不知要怎么写那个组合键!
有没哪个大侠放一段这个的代码或写一段
http://topic.csdn.net/u/20090609/15/7dc9fb70-243f-4070-9cfd-34e48b66e6c6.html
......
void guibing(int a[],int n)
{
}
我已经初始化了一个数组a[30000]且赋值,想对这个数组进行归并排序。
但是具体怎么实现还是不知道。求源码
比如说。先一个一个排序,然后再将排序好的两个两个排序。那么这个排 ......