One more function I need help on
hi guys,
I got the WhereIs function(thank for the hint Stoned Code) but now I need your help on another one. Same header file as before but this is an Insert(int, int) function
Code:
bool List::Insert(int value, int pos)
// inserts a number in the list, possibly in the middle(if room, and if valid position given)
{
if (element < SIZE){
int new_element = element;
// shift all values at pos, one element to the right
for(int i = element; i >= pos; i--)
list_array[i + 1] = list_array[i];
// insert new value
list_array[pos] = value;
// increase the size of the array
element = (new_element + 1);
return true;
}
else{
cout << "*** Invalid list position number\n";
return false;
}
}
This function should insert a value at a specified location (if room) if there is no room it should send a false return statement. There's something in here I can't catch Hopefully, you guys can find the error. Thank you.