Hey there. I'm getting some odd errors trying to work on a quick sort example. It seems like I'm not using my templated parameters correctly. It's making T an int* when I want T to be just int. I thought by using <class T> and <T* arr ... I would be able to get a pointer of type T. When I call quick sort I'm passing a reference to T, so that I can change the values in the sorted arrays. I'm guessing this is the error, but ... yeah. I've rambled enough.
-edit-
So, in case anyone googles for these errors ...
don't pass arrays by address into templated functions. The pointers seem to work just fine.
Problem solved.
Code:
"exampleSort.c", line 88: error: initialization with "{...}" expected for
aggregate object
T pivot = array[startIndex];//pivot element is the leftmost element
^
detected during instantiation of
"void QuickSort(T *, int, int) [with T=int [10]]"
"exampleSort.c", line 95: error: no instance of function template "SplitArray"
matches the argument list
argument types are: (int (*)[10], int [10], int, int)
splitPoint = SplitArray(array, pivot, startIndex, endIndex);
^
detected during instantiation of
"void QuickSort(T *, int, int) [with T=int [10]]"
"exampleSort.c", line 99: error: expression must be a modifiable lvalue
array[splitPoint] = pivot;
^
detected during instantiation of
"void QuickSort(T *, int, int) [with T=int [10]]"