Boost logo

Boost Users :

From: Peter Piehler (ppiehler_at_[hidden])
Date: 2004-07-04 05:31:41


I use call<void>(pyFunc,arg1,..) to call a python
function with standard double, int etc.

What must I do to call a function with a c++ object as


class MyAnimal
       std::string __strName;
       MyAnimal() : __strName("Tux") {}
       std::string getName()
           { return __strName;}
       void setName(const std::string &strName)
           { __strName = strName; }

int main()
  MyAnimal* pTux = new Animal;
  /*do something with pTux*/

  /*use a python function with pTux*/
  call<void>(pyFunc1, ?pTux? );
  /*change attributes pTux in pyFunc2*/
  dog = call<MyAnimal>(pyFunc2, ?pTux?);

  /*if it possible to call by reference?*/
  call<void>(pyFunc3, ?pTux?);
  pTux->getName();// return Cat


python module:

def py_func1(a):
     print a.getName()

def py_func2(a):
     return a

def py_funnc3(a):


Gesendet von Yahoo! Mail - Jetzt mit 100MB Speicher kostenlos - Hier anmelden:

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at