title: Subscript Operator Overloading Error
body: <p>This is a function within my doubly linked list class, but every time I compile, I get this message: "Invalid initialization of non-const reference of type 'int&amp;' from a temporary of type 'int'. I just can't get how else to do it.</p>
  
  <pre><code>int&amp; LinkedList::operator[](int index)
  {
      Node* current = head_;
  
      for(int i = 0; i &lt; index; i++){
          current = current-&gt;getNextNode();
      }
  
      return(current-&gt;getValue()); // getValue() returns an int
  } 
  </code></pre>
  
  <p>Thanks in advance!</p>