I have a property of a class, for example, const CFoo &bar() const, what does it mean?
const CFoo &bar() const
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).
bar
CFoo
const CFoo &
mutable
const
See also the C++ FAQ Lite entries What does "Fred const& X" mean? and What is a "const member function"?.
Fred const& X
1.4m articles
1.4m replys
5 comments
57.0k users