-
Need way to end
I need a way for this recursive to end when the item is not in the list. Can you help? Thanks!!
Code:
template <typename T>
class List
{
private:
T * array;//memory for array will be dynamic
int insert(T * array, T item, int size);
void List::insert (int index, ListItemType newItem,
bool& success)
{
success = bool( (index >= 1) &&
(index <= size +1) &&
(size < MAX_LIST) );
if (success)
{
items[translate(index)]=newitem;
++size;
insert(index+1,newitem,success);
}
}
-
The insert function does not match in the interface and implementation.
One solution is to do the check before the if statement.
Kuphryn
-
Ok, not sure how to do that. Would it be another if statement?
-
How about, search the array and if the value is found return the location of the value, that is the value in position 1 or 6 or ?. How do I do that?
Thanks!!