Actually this is what I have now. I am getting an error that I don't have a default value for parameters 3 and 4 in my binarySearchImpl function declaration in the class definition.
declaration statment:
Code:
private:
int binarySearchImpl(const elemType& item, int first = 0, int last, int count);
And there are the two function definitions:
Code:
template<class elemType>
int orderedArrayListType<elemType>::binarySearch(const elemType& item)
{
first = 0;
last = length - 1;
mid = last - first / 2;
return binarySearchImpl(item, first, last, mid);
}
//Function written for Test 5 Question 22
template<class elemType>
int orderedArrayListType<elemType>::binarySearchImpl(const elemType& item, int first, int last, int count)
{
if(first > last || count == last || count == first)
return -1;
if(list[count] == item)
return count;
else if (list[count] > item)
{
count--;
return binarySearchImpl(item, first, last, count);
}
else
{
count++;
return binarySearchImpl(item, first, last, count);
}
}//end binarySearch