template <typename T>
void QuickSort( T array[], int index[], int start, int finish ) {
int counter;
int left = start;
int right = finish;
T pivot = array[index[(start + finish) / 2]];
do {
while ( array[index[left]] < pivot ) {
left++;
}
while ( array[index[right]] > pivot ) {
right--;
}
if ( left <= right ) {
Swap(&index[left], &index[right]);
left++;
right--;
}
} while ( left < right );
if ( start < right ) {
QuickSort(array, index, start, right);
}
if ( left < finish ) {
QuickSort(array, index, left, finish);
}
}
int main() {
Dictionary dictionary;
vector<string> wrapped;
int i;
int arr[5] = {3, 2, 4, 1, 5};
int index[5] = {1, 2, 3, 4, 5};
QuickSort(arr, index, 0, 4);
for ( i = 0; i < 5; i++ ) {
cout << arr[index[i]];
}
wrapped = wordwrap("A quick brown fox jumped over the hollow log. A quick brown fox jumped over the hollow log. A quick brown fox jumped over the hollow log.", 20);
for ( i = 0; i < wrapped.size(); i++ ) {
cout << wrapped[i] << "\n";
}
MainMenu(dictionary);
Pause();
return 0;
}
C:\Dev-Cpp\Projects\Dictionary 2\sorting.cpp In function `void QuickSort(T*, int*, int, int) [with T = int]':
327 C:\Dev-Cpp\Projects\Dictionary 2\main.cpp instantiated from here
25 C:\Dev-Cpp\Projects\Dictionary 2\sorting.cpp invalid initialization of non-const reference of type 'int*&' from a temporary of type 'int*'
3 C:\Dev-Cpp\Projects\Dictionary 2\sorting.cpp in passing argument 1 of `void Swap(T&, T&) [with T = int*]'