Question: I am very confused about the const version and non-const version member function like below:

```
value_type& top() { return this.item }
const value_type& top() const { return this.item }

```

What is the difference between these two functions? In what situation would they be used?

Answer: 
The const-qualified member function will be called if the member function is called on an object that is const-qualified.

The non-const-qualified member function will be called if the member function is called on an object that is not const-qualified.

For example:

```
MyStack s;
s.top(); // calls non-const member function

const MyStack t;
t.top(); // calls const member function

```

Note that the same rules apply when calling a member function on a reference to an object or through a pointer to an object: if the pointer or reference is to a const object, the const member function will be called; otherwise the non-const member function will be called.
When member function is declared as `const` what's happening is that the implicit `this` pointer parameter passed to the function is typed to be a pointer to a const object. This allows the function to be called using a const object instance.

```
value_type& top();    // this function cannot be called using a `const` object
const value_type& top() const; // this function can be called on a `const` object

```