Thursday 1 November 2012

Revised version of Amir and Saeid's code - OOP344

Changed Fardad's function signature so that returned data is a reference to the original, thus able to be modified

//queue.h
int& operator[](unsigned int index);


Simplified version of Amir and Saeid's operator function, removed extra variables and LOC. Their other functions remain the same.

//queue.cpp
int& Queue::operator[](unsigned int index){
  Node* Ind = _head;
  int i;
  for (i = 0; i < index % _size; i++){
    Ind = Ind-> _next;
  }
  return Ind-> _data;
}

No comments:

Post a Comment