I'm having trouble with a school project. This project runs on commands inputted though the terminal. The problem I'm having is that when I type in the commands: "+a +b +c +d" (insert a, b, c, d) the program breaks at inserting b... so somewhere in the insert command it is screwed up. I'm not sure what though, and if I could be pointed in the right direction! Please edit mycode and post it as last resort... if I could be pointed in the right direction first...
Here is the code for insert:
template <class LE>
void List<LE>::insert ( const LE &newElement ) // Insert after cursor
{
if (maxSize != size)
{
if (size != 0)
{
for(int i = (size); i <= (cursor + 1); i--)
element[i] = element[(i-1)];
element[cursor] = newElement;
cursor++;
}
else
{
element[0] = newElement;
cursor = 0;
}
size++;
}
}
I have a feeling it is some kind of logic error, but I'm not sure... I've worked it out on paper, and it seems right.
Here are the individual files:
LISTARR.cpp
LISTARR.h
SHOW4.cpp
TEST4.cpp
If you want to see the whole project in a zip file click here
Thank you!
Avaviel