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

Francois Ostiguy ostiguy at fnal.gov
Fri Feb 27 22:18:06 CET 2004


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

a = A()
a.s.h = 1.0
a.s.v = 2.0
a2 = A()
a2.s.h = 3.0
a2.s.v = 4.0

As usual, I am grateful for any help or hints.

-Francois

----------------------------------------------------------------------------
Dr. Jean-Francois OSTIGUY                              voice: (630) 840-2231
Beam Physics Dept MS220                                  FAX: (630) 840-6039
Fermi National Accelerator Laboratory                email: ostiguy at fnal.gov
Batavia IL 60510-0500                           WWW:www-ap.fnal.gov/~ostiguy





More information about the Cplusplus-sig mailing list