[C++-sig] static data members
Francois Ostiguy
ostiguy at fnal.gov
Tue Oct 8 22:40:34 CEST 2002
> > Quick question -
> >
> > How to I expose static class data members ? Can you supply a short
> > example ?
>
> object x_class
> = class_<X>("X")
> .def( ... )
> ...
> ;
>
> x_class.attr("fu") = X::fu;
> x_class.attr("bar") = X::bar;
> ...
>
I am stumped. I cannot get the code below to compile.
I get the following message from g++ 3.1.1:
py-ring.cc: In function `void init_module_ring()':
py-ring.cc:26: parse error before `=' token
module("ring")
.add (
ring_class = class_<Ring>("Ring", python::args<>() )
.def("doTurn", &Ring::doTurn)
);
ring_class.attr("nodesInitialized") = Ring::nodesInitialized;
...
where
Ring::nodesInitialized is a static variable
Ring::doTurn is a static method
Ring has both static and non-static data/function members.
-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