[C++-sig] Problems with pure virtual methods.

Jeff Holle jeff.holle at verizon.net
Thu Apr 29 02:14:56 CEST 2004


In using Boost.Python version 1_31_0 with pyste version 0.9.28, and gcc 
version 3.3, I've run into a problem with pure virtual methods.

The problem is expressed a calling a base class method that employs an 
abstract method also defined in the same class.

I'm providing an example that  demonstrates  the problem.

The solution is to give the abstract method an implementation in the 
base class (making it just a virtual method).  Note that this is far 
from desirable in that it precludes the use of abstract methods.

The actual python runtime error can vary with this problem.  With the 
provided
example the error is:
  ReferenceError: Attempt to return dangling reference to object of 
type: std::string
-------------- next part --------------
A non-text attachment was scrubbed...
Name: abstractMethod.gz
Type: application/x-tar
Size: 2241 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040428/ca60a709/attachment.tar>


More information about the Cplusplus-sig mailing list