What is the difference between inspector and a mutator?

An inspector is a member function that returns information about an object's state without changing the object's abstract state (that is, calling an inspector does not cause an observable change in the behavior of any of the object's member functions). A mutator changes the state of an object in a way that is observable to outsiders: it changes the object's abstract state. Here is an example.
class ShoppingCart {
public:
int addItem(); //Mutator
int numItems() const; //Inspector
};
The addItems() member function is a mutator because it changes the ShoppingCart by adding an item. The numItems() member function is an inspector because it simply counts the number of items in the ShoppingCart without making any observable changes to the cart. The const decoration after numItems() indicates that numItems() promises not to change the ShoppingCart object.
Only inspectors may be called on a reference-to-const or pointer-to-const:
void sample(const ShoppingCart& s) throw()
{
s.numItems(); // OK: A const ShoppingCart can be inspected
s.pop(); // Error: A const ShoppingCart cannot be mutated
}