R
Richard Herring
In message said:Richard said:Right there:Rolf Magnus said:Richard Herring wrote:
Just do this:
cat foo.cc
class foo {
private:
// representation
float a[3];
public:
// functions
const
float& x(void) const { return a[0]; }
Const function returning non-const reference to member? Are you sure?
Where?
A constant function taking no arguments and returning a non-constfloat& x(void) const { return a[0]; }
reference to a float, namely a[0].
I guess you're not so good at reading declarations that span two lines,
are you?
Only when I write them ;-)
It's been a long day. I take that point back, and substitute a
different one. Who on earth splits that kind of declaration over two
lines, unless they deliberately intend to cause confusion?
Just look at the line _preceding_ the one you're referring to.
But my comment about the following line still stands.