Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¹ØÓÚ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


Ïà¹ØÎÊ´ð£º

ѧϰÌÖÂÛ C/C++ QQȺ - C/C++ / ·Ç¼¼ÊõÇø

QQȺ 29152388
ÓÑÇéUP

°ï¶¥

up

°ïup

up Ö§³Ö£¡

up jf

...ÄѵÀÓзÖ..?

up up up
Ï£ÍûÓеüӷ֣¬¹þ¹þ¡£

Ö§³Ö£¬ÎÒ¼ÓÁË£¬Ï£ÍûÂ¥Ö÷ÄܼÓÎÒ£¬¹²Í¬Ñ§Ï°¹þ

¼ÓÁË¡£

¶¥ÉÏ£¬Ã¿ÌìÊÕ»ñÒ»µã£¬Ö§³Ö ......

[Çó¸Ö²ÄÇиîÎÊÌâµÄC/C++Ë㷨ʵÏÖ]

ÎÊÌâ:¹¤µØÉÏÐèÒª³¤¶ÈΪA1µÄ¸Ö½îX¸ù,³¤¶ÈΪA2µÄ¸Ö½îY¸ù,³¤¶ÈΪA3µÄ¸Ö½îZ¸ù......ÒÔ´ÎÀàÍÆ.
ÆäÖÐA1,A2,A3,...³¤¶ÈÈÎÒâÖ¸¶¨,X,Y,Z,...ÊýÁ¿Ò²ÈÎÒâÖ¸¶¨.

µ«²Ö¿âÖеĸֽîΪ±ê×¼³¤¶È,Ö»ÓÐ9Ã׺Í15Ã×Á½ÖÖ³¤¶È,ÊýÁ¿² ......

execlÔõôµ÷ÓÃjava³ÌÐò - C/C++ / CÓïÑÔ

ÈçÌ⣬C/C++ÖеÄexeclÔõôµ÷ÓÃдºÃµÄjava³ÌÐò£¬
execl("/opt/java1.5/bin/java","MyClass",NULL);
ÕâÑùµÄ²»ÐÐŶ¡£

²»»á.

ÔËÐÐjava³ÌÐò
ÕÒ¹¤¾ß²é¿´Ò»ÏÂÄǸö³ÌÐòµÄÃüÁîÐÐ

ËÑË÷Ï£ºjni ......

cȺ - C/C++ / ·Ç¼¼ÊõÇø

±¾ÈËѧϰcÒÑÓÐÈýÄêʱ¼ä ÎÒ¸Õ½¨ÁËÒ»¸öȺ ÓжÔc¸ÐÐËȤµÄ¿ÉÒÔ¼ÓÈë »¶Ó­´ó¼ÒȺºÅÊÇ£º91975736
½Ó·Ö

Â¥Ö÷Ҫѧ»á½áÌù£¬½Ó·Ö

ÄãÃDz»ÊÇ»¹Ã»ÓмÓÈëÂð ÎÒ¸ÉÂï½áÌùÄØ ºÇºÇ

QQÊÇʲô£¿Ò»ÖÖʳÎïÂð£¿

ÎÒÏë¼Ó

¼ÓÍêÁ ......

CµÄѧϰ;¾¶ - C/C++ / ÐÂÊÖÀÖÔ°

ÎÒֻѧ¹ýÇ廪À¶·âÃæµÄCÓïÑÔ»ù´¡£¬Ïë¸üÉîÈëµÄѧϰ£¬¸Ã¿´Ê²Ã´ÊéºÃ£¿
C Primer Plus
C³ÌÐòÉè¼ÆÓïÑÔ(µÚ2°æÐ°æ)
CÓïÑÔ³ÌÐòÉè¼Æ_ÏÖ´ú·½·¨
CÓïÑԲο¼ÊÖ²áµÚÎå°æ
CÓïÑÔ´óÈ«
CºÍÖ¸Õë
CÏÝÚåÓëȱÏÝ
Cר¼Ò±à³Ì

......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ