Jonathan Turkanis said:
Were talking about "Avoid member functions that return pointers or
references to
members
less accessible than themselves," right?
Not exactly. The reason I jumped in was that Mr. Meyers' whole point
revolved around the reference being non-const. He was just showing one way
that data that should be private can be exposed via a public interface, and
that such a thing be avoided by using a const reference instead.
This is the same as my example, and I'm arguing that contrary to Meyers,
sometimes it's okay. I've given the argument twice now.
I will certainly concede that sometimes it is appropriate, and maybe even
needed. Mr. Meyers' statement was to "avoid" such a thing, which in my
opinion leaves plenty of room for "sometimes".
And I still feel he's
got a valid point, certainly not rubbish, even if it wouldn't make a good
"hard and fast rule". Something to at least consider when designing a class
with private data, certainly. But really, my whole point in being here was
to correct the OP's posting that left off the critical "non-const" part, not
to argue the validity or scope of Mr. Meyers' argument.
-Howard