1.

Differentiate Between An Inspector And A Mutator ?

Answer»

ANSWER :An inspector is a member function that returns information about an object's STATE (information stored in object's data members) without changing the object's state. A mutator is a member function that changes the state of an object. In the class Stack given below we have defined a mutator and an inspector. class Stack { public : int POP( ) ; int getcount( ) ; } In the above example, the function pop( ) removes top element of stack thereby changing the state of an object. So, the function pop( ) is a mutator. The function getcount( ) is an inspector because it SIMPLY counts the NUMBER of elements in the stack without changing the stack.



Discussion

No Comment Found