0
#ifndef SORT_LIB_H
#define SORT_LIB_H

template <typename T>
class Sort
{
private:
	static int FindNextMinIndex(T arr[], const int start, const int length);
	static void Swap(T arr[], const int index1, const int index2);

public:
	static void SelectionSort(T arr[], const int length);

};



template <typename T>
int Sort<T>::FindNextMinIndex(T arr[], const int start, const int length)
{
	int minIndex = start;
	for (int i = start + 1; i <= length - 1; i++)
		if (arr[i] < arr[minIndex])	minIndex = i;

	return (minIndex);
}


template <typename T>
void Sort<T>::Swap(T arr[], const int index1, const int index2)
{
	T tmp = arr[index1];
	arr[index1] = arr[index2];
	arr[index2] = tmp;
}


template <typename T>
void Sort<T>::SelectionSort(T arr[], const int length)
{
	for (int top = 0; top <= length - 2; top++)
	{
		int minIndex = FindNextMinIndex(arr, top, length);
		Swap(arr, top, minIndex);
	}
}

#endif
Error	1	error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class ArrayList<int> const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$ArrayList@H@@@Z) referenced in function _main	p04.obj

Any help?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by StuXYZ
0

Looks like you have given us the wrong class. Your problem seems with arrayList not Sort. Which if you add a quick test, works.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.