[C++-sig] [boost.python] Exposing interfaces to python

Maximilian Matthe Maxi.Matthe at web.de
Wed Jul 16 11:12:23 CEST 2008


Hello!

I want to expose an abstract class to python:

class abstract
{
   public:
   virtual void f() = 0;
};

Then I want to write a function in python that accepts pointers
to abstract:

def func(abs):
   abs.f()

In c++ I want to derive a concrete class from abstract:
class concrete : public abstract
{
public:
   virtual void f() { cout << "Hi" << endl; }
}

Then I want to call the python function func with a pointer to
a concrete object, so that func prints out "Hi".

How can I achieve this? I do not want that users of python can derive
from abstract, I just want to give python the interface to my class
and pass pointers of concrete classes to this function.

Are there possibilities?




More information about the Cplusplus-sig mailing list