I have a property of a class, for example, const CFoo &bar() const
, what does it mean?
I have a property of a class, for example, const CFoo &bar() const
, what does it mean?
The method bar
returns a reference to a const CFoo
(that's the const CFoo &
part before bar
), and calling this method does not modify any variables that are not marked as mutable
(that's the const
after the parentheses).
See also the C++ FAQ Lite entries What does "Fred const& X
" mean? and What is a "const
member function"?.