[C++-sig] module destructor?
Stefan Seefeld
seefeld at sympatico.ca
Mon Mar 5 15:04:58 CET 2007
Neal Becker wrote:
> Thanks. I've never tried to instantiate an object from c++. Any
> examples/hints?
-----
#include <boost/python.hpp>
#include <iostream>
struct Guard
{
Guard() { std::cout << "default constructor" << std::endl;}
Guard(Guard const &) { std::cout << "copy constructor" << std::endl;}
~Guard() { std::cout << "destructor" << std::endl;}
};
using namespace boost::python;
BOOST_PYTHON_MODULE(bpl)
{
class_<Guard> a("Guard");
scope().attr("_hidden") = Guard();
}
-----
(As you will see running this code, the object here is passed
by value, so you'll actually get two. You may want to change
that...)
HTH,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig
mailing list