I am working on a C++ project that requires us to make a class that makes a list able to use random access.
I have made a class RAList<Temp> (Random Access list) that inherits from list<Temp>.
I have random access working correcty with the [] operator, but i am stuck on the next part. Here are the instructions given:
"list<ELEM>::iterator +, allows an iterator to it = it + 5 which will increment the iterator to point to the fifth element from the current position "
I have somewhat of a solution but it does not meet those requirments, right now I am implementing the + operator in the RAList class and I iterate n number of time until I get to the iterator that is "n" away from its current iterator, problem with this is when I use the code it looks something like this:
RAList<int> intList;
// populate intList....
RAList<int>::iterator itInt;
itInt = intList + 5;
and this does not follow the it = it + 5 format, is acually it = RAList<int> + 5.
Anyone know how I would be able to implement this solution?
Thanks in advanced,
Matt



LinkBack URL
About LinkBacks



Want to add some
, but for now lets stick to the task at hand, getting + operator working.