I have an assignment which involves different linked list operations. One of them involves overloading the square bracket operator to be able to print the ith element of the linked list. I have everything else done but I am really lost on this. This is what I am working with. The list class is as follows:
class List {
public:
// Creates a default empty list
List();
// Simple destructor
~List();
// Insert "data" at the very end of the list
void AddToFront(int data);
// Remove and return the first data item from the list.
int deleteFront();
// Prints the list
void Print() ;
// Returns the size of the list
unsigned int Size() const;
//overloaded assignment operator
Node operator[](unsigned int i) ;
private:
Node *m_head;
};
Also, here is my node class:
class Node {
public:
Node();
~Node();
Node(int data);
int m_data;
Node *m_next;
};
Any help on the overloading [] operator would be greatly appreciated.