次のように、cpp関数でテンプレート化されたクイックソートメソッドを参照しています。
Main.cpp
QuickSort<vector<int>>(testData);
testDataは次のとおりです。
int arr[] = {0, 5, 3, 4, 2, 1, 4};
vector<int> testData (arr, arr + sizeof(arr) / sizeof(arr[0]));
.hファイルでのクイックソートの宣言は次のとおりです。
Sorting.h
template <typename T>
void QuickSort(std::vector<T>& Unsorted);
そして、関数の定義は次のとおりです。
Sorting.cpp
template <typename T>
void QuickSort(std::vector<T>& Unsorted)
{
//implementation here
}
私は心を失っていますか?参照によってintのベクトルを渡そうとしています。誰かが私がどこで間違っているのか教えてもらえますか?