ragged_hippy said:
But yes I immediately got his huge set of compiler errors which I didn't
expect.
Try to read any C++ book about pointers, references and variables, try find
its representation in memory.
Internally reference can be implemented as const pointer, but for C++ users
reference has special behaviour. After reference has been created, you can
not access to the reference itself (can not to the reference internal
address), only to object the reference refers to.
It looks like reference has no default ctor
const X &tmp; //error
also reference can not be reassigned, as if automatically forwarding all its
messages to own stored X object.
const X &tmp=*static_cast<X*>(0);
const X obj;
tmp=obj;
is not the same as
const X obj;
const X &tmp=obj;
The purpose of reference is hiding own existance. So if you do not want the
hiding. If you need address, use POD pointers. If you need ownership of
dynamic memory, use RAII wrappers (as auto_ptr). Else use object itself.
--
Maksim A. Polyanin
http://grizlyk1.narod.ru/cpp_new
"In thi world of fairy tales rolls are liked olso"
/Gnume/