I have been given this template:
Code:
template <typename T>
int addInOrder(T* array, int& size, T value)
{
// Make room for the insertion
int toBeMoved = size - 1;
while (toBeMoved >= 0 && value < array[toBeMoved]) {
array[toBeMoved+1] = array[toBeMoved];
--toBeMoved;
}
// Insert the new value
array[toBeMoved+1] = value;
++size;
return toBeMoved+1;
}
This template is in a header file which is included in my cpp file.
Now, apparently I am not using it correctly in a function I have created in the cpp file.
This is my usage:
Code:
addInOrder(locators, MaxPages, located);
where locators is the array, MaxPages is the array length, and located is what needs to be inserted.
Something is wrong because it isn't compiling. Any help would be appreciated. Thanks.