[C++-sig] C++ derived from bp::dict

Michael Andronov michael_andronov at sd-kyber.com
Thu Feb 10 21:19:08 CET 2011


Hi,

Being a newbie to boost::python, I have a  question ( hopefully
simple), which failed to find the answer in mail logs:

let's say
a.  I have a  C++ class, derived from boost::python::dict ;
b.  I would like later to get access to myLong, and to the dictionary,
my class derived from.

Would mentioning the boost::python::dict as a base wtihin wrapping
section be enough to get access to dictionary?
(Something like...
"
....
class myd :boost::python::dict {
...
  public:
     unsigned long myLong;
}

BOOST_PYTHON_MODULE(mymod)
{
   using namespace boost::python;

   class_<myd, bases<dict> > ("mydict")
		         .def_readwrite("pd", &myd::pd);
   ...
}	

Thanks.

Michael.


More information about the Cplusplus-sig mailing list