The above is a minimalist example to illustrate my question...Code:class myClass { public: myClass(): val(0), value(val) {} myClass(int x): val(x), value(val) {} void set_value(int x) { val = x; } private: int val; public: const int &value; };
Instead of coding getters for every data member, is the const reference considered a correct approach within the context of good programming practices under C++?
EDIT: I understand this forces me to overload the assignment operator. But still... is this a common practice?