从C ++代码调用python类的方法

Zak*_*sey 5 c++ python linux boost boost-python

例如,让我们考虑pythonfile中具有以下结构的类mult.py

mult.py

class Mult: 
      def __init__(self, first, second):
            self.a = first 
            self.b = second 

      def multiply(self):
            c = self.a*self.b
            print 'The result of', self.a, 'x', self.b, ':', c
            return c
Run Code Online (Sandbox Code Playgroud)

我们如何multiplyC++Code中从上面的类调用方法?(但没有PyRun_SimpleString()功能)

main.cpp

#include<python2.7/Python.h>
#include <boost/python.hpp>

int main()
{
     Py_Initialize();
     int a {10};
     int b {5};
     ... CODE HERE (a*b using python function)
     Py_Finalize();
}
Run Code Online (Sandbox Code Playgroud)

我当时在寻找解决方案Cythonboost.python但找不到。

附加链接: