What is the meaning of const
in declarations like these? The const
confuses me.
class foobar
{
public:
operator int () const
Blair's answer is on the mark.
However note that there is a mutable
qualifier which may be added to a class's data members. Any member so marked can be modified in a const
method without violating the const
contract.
You might want to use this (for example) if you want an object to remember how many times a particular method is called, whilst not affecting the "logical" constness of that method.