c++ - Destructor and python -
i have base class in c++. export python using boost::python. virtual destructor? base class should have virtual destructor avoid wrong memory freeing, right? forget , wrote base without destructor. works, lot of memory leaks.
now i've added:
class base { public: virtual ~base(); // other members... }; and after importing of module in python error:
importerror: base.so: undefined symbol: _zti6base
what i'm doing wrong? and, understand, error causes due missing destructor exporter py-module.
the missing symbol error caused failing define destructor (you're declaring destructor, it's unclear question whether you're defining it):
class base { public: virtual ~base() {} // other members... }; (note added curly braces)
as question whether every "base class should have virtual destructor avoid wrong memory freeing", please take @ faq: http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.7
Comments
Post a Comment