I'm working on brushing up on my C++ during some project downtime and have created a a Linked List project to do so. In this project I would like to return the current value at a set index. I've already got a method to do this, but want to work it out with an operator overload.

To that end I did the necessary research to brush up and have created the following code (I won't subject everyone to my code and will only paste the pertinent sections):

```
T& operator[](const int index);

template<class T>
T& LinkedList<T>::operator[](const int index)
{
  try
  {
    if(!isIndexValid(index)) throw ior;

    Node<T> *temp = _head;
    for(int i=1; i<=index; i++)
    {
      temp = temp->Next;
    }

    return temp->Value;
  }
  catch(exception& e)
  {
    cout << e.what() << endl;
  }
}

```

In my main function I have the following line:

```
int foo = list[5];

```

Everything looks good to me, but when I compile I get the following error:

```
error C2440: 'initializing' : cannot convert from 'LinkedList<T>' to 'int'

```

Does anyone have any ideas how to fix this?

Thank you!

For those that have asked, here is how the Node class is defined:

```
template<class T>
class Node
{
  public:
    Node();
    Node(const T value);

    T Value;
    Node<T> *Prev;
    Node<T> *Next;
};

```

And here is the declaration for my list variable:

```
LinkedList<int> *list = new LinkedList<int>();

```