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