[C++-sig] exposing a class with a member class object

Nicodemus nicodemus at esss.com.br
Fri Feb 27 23:00:30 CET 2004


Hi,

Francois Ostiguy wrote:

>Hi -
>
>Using boost.python, I am trying to expose an object member from a class.
>As a simple example, consider :
>
>class A {
>
> A( double x, double y): s.h(0.0), s.v(0.0) {}
>
> struct S { double h, double v } s;
>
>};
>
>I would like the C++ type A to be mapped into a corresponding Python type
>that once instantiated can be used with the obvious syntax
>  
>

Hope that helps (untested):

{
scope s (

class_<A>("A", init<double, double>());

);

class_<S>("S")...;
}


Cheers,
Nicodemus.





More information about the Cplusplus-sig mailing list