I have been given this template:
This template is in a header file which is included in my cpp file.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;
}
Now, apparently I am not using it correctly in a function I have created in the cpp file.
This is my usage:
where locators is the array, MaxPages is the array length, and located is what needs to be inserted.Code:addInOrder(locators, MaxPages, located);
Something is wrong because it isn't compiling. Any help would be appreciated. Thanks.