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: 
If you have 

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

```

If you have

```
Foo foo;
const Foo cfoo;

```

The return types when you call `top()` are as follows:

```
value_type& bar = foo.top();
const value_type& cbar = cfoo.top();

```

In other words - if you have a constant instance of your class, the const version of the function is chosen as the overload to call.

The reason for this (in this particular case) is so that you can give out references to members (like `item` in this case) from a const instance of a class, and ensure that they too are const - thus unmodifiable and therefore preserving the const-ness of the instance they came from.
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

```