我有以下类定义:
class foo {
private:
bool m_active;
public:
const bool isActive() const // (btw do I need return type `const bool&` here?)
{
return m_active;
}
};
具有
const
getter(foo->isActive()
)的类的工作速度是否比foo->m_active
(如果它将是公共的)更快? 我试图查看反汇编的代码,但没有发现任何有趣的东西。在哪里可以阅读有关
const
getter和setter的信息? 我需要深入了解在何处以及为什么使用这些方法。