[C++-sig] Returning reference to member variable that's a basic type

Joel Gerard llywelyn.geo at yahoo.com
Sat Oct 4 01:03:42 CEST 2003


I hope this doesn't get me the dumb question of the day award but...

How do you return a pointer/reference to a member variable(a basic type) and modify it from
python?

Eg.

Class Foo
{
public:
    int *GetX() {return x;};
    int &GetY();
private:
    int *x;
}

I've tried

.def ("GetX()",&Foo::GetX, return_internal_reference<>())
.def ("GetY()",&Foo::GetY, return_internal_reference<>())

I have no problems returning objects, but basic types gives me this error:

d:\dev\libs\boost\boost\python\object\make_instance.hpp(25): error C2027: use of undefined type
'boost::STATIC_ASSERTION_FAILURE<x>'
        with
        [
            x=false
        ]

What am I doing wrong?

Thanks,
Joel

=====
--------------------------------------
Email: joelgerard at canada.com

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com




More information about the Cplusplus-sig mailing list