I am writing a C ++ accessor to a class member as
SomeClass const& x() const { return m_x; }
It seems that the only protection of this type in C # is to define a property with a closed (or undefined) set. But this protects only from assignments, and not from manipulating the state of a certain class.
Side note: C ++ allows m_x to be removed using the const pointer - IMHO is just an amazing oversight of standard bodies.
source
share