class Test { private: int m_val; public: };
下面两个哪个函数写法正确,为什么?
int &get_m_val() const { return m_val; }
const int &get_m_val() const { return m_val; }
下面那个是正确的。或者int &get_m_val() {return m_val;}