returning reference to private vs public member
问题 I would like to know what could be reasons to provide a public access method returning a reference instead of making the member public. QPoint has methods int& rx and int& ry that let me directly manipulate the coordinates. I guess the implentation looks similar to this: public: int& rx(){return x;} private: int x; The only idea I had so far is the following: By keeping the member private and "only" providing a reference, the class can still change to use a different data type for its