[C++-sig] Constructors in callback classes.

Brett Calcott brett.calcott at paradise.net.nz
Sat Nov 9 02:12:03 CET 2002


Hi,

Callback classes look like this:

   class py_agent : public agent
   {
   public:
      py_agent(PyObject* self) : m_self(self) {}

      char const *do_something() const
      {
         using namespace boost::python;
         return call_method<char const*>(m_self, "do_something");
      }

      PyObject* const m_self;

   };

But what if the parent class "agent" has no default constructor. Can I pass
through arguments as well as the PyObject * ? It wasn't obvious what I
should do here.

Cheers,
Brett





More information about the Cplusplus-sig mailing list