| Code: |
|
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <iostream> #include <iomanip> #include <string> template <class W> friend int& operator [](List<W> &item, int W); template <class W> int& operator [](List<W> &item, int W) { struct node <W> * temp = item.root; while(temp->next->count != W) { temp->data; temp=temp->next; } return temp->data; } |
I receive this compile error.
`int& operator[](List<W>&, int)' must be a nonstatic member function
What im suposta do is write a function to overload the [] operator so that it acts like an index of an array on a linked list. What am I doing wrong? it looks fine to me.
