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"?.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With