Interpreting C++ stub code

I want to write code to complete a C++ stub generated automatically from a definition file. I can do this by simply following instructions, but as a non-C++ programmer I am struggling to understand how the underlying code works.

The stub contains an object declaration with a private instance method that looks like this:
CIEC_UINT &GETDATA() {
return *static_cast<CIEC_UINT*>(getDO(3));
};

I am told that both of the following statements are valid:
local_var = GETDATA();
and
GETDATA() = local_var;

The first statements aligns with my experience of other languages, but the second would be illegal in most.

How does this work? I have tried to think of GETDATA() as a funtion, as a pointer, as an array - nothing really makes sense.
GETDATA() is a normal function that returns a reference to CIEC_UINT. A reference is an alias for the object it was bound to (the object resulting from the getDO()/static_cast combination), so it is possible to assign a value to it, as in GETDATA() = local_var;
The function itself returns a reference, which means it can be modified. You might think of a reference as an always-dereferenced pointer with some other restrictions.
Thanks, folks.
Topic archived. No new replies allowed.