SWIG and abstract base class

Lyle Johnson ljohnson at resgen.com
Thu Mar 7 11:41:47 EST 2002


> I want to use SWIG to create a Python module for
> a C++ class hierarchy using abstract base classes:
>
> class Base // Abstract base class
> {
> public:
>   // many common methods
>   ..
> };
>
> In the created C++ code, I get error messages like
>
> "cannot instantiate abstract class due to following members:"
>
> Is there any possibility to tell SWIG that
> Base should be treated as abstract class?

Are you declaring a (public) constructor for the "Base" class in your SWIG
interface file? Or maybe passing the "-make_default" flag to SWIG, to tell
it to create default constructors for classes that don't already declare
one? It sounds like there's a function declared *somewhere* in your SWIG
interface that leads SWIG to believe it can directly create instances of the
"Base" class.





More information about the Python-list mailing list