nstring &
list::operator [] (int index) const {
n node * current = head;
n for (int i=0; i< index &&
current; i++)
n current = current->next;
n if (!current) {
n //consider what other alternatives there
are
n string * temp = new string; //just in
case
n return *temp;
n }
n return current->obj;
n}
n
nNotice how we must consider each special case (such as
an index that goes beyond
the number of nodes provided in the
linked list
n