Is it possible to return a reference to a member variable in such a way as to prevent it from being altered (thereby changing the state of the object)? The following code does not prevent this!
Code:
 
class X
{
};
 
class Y
{
public:
	 const X& get () const { return _x; }
 
private:
	 X _x;
};
This does not stop someone from doing the following...
Code:
int main ()
{
X x;
Y y;
 
const_cast<X&> (y.get ()) = x;
}