template class Set { private: T *arr; int length; int pos; public: Set(void); ~Set(void); void addVal(const T&); void printVec(void); void insertSort(void); int getLength(void); int getPos(void); }; template Set ::Set(void) { length = 50; pos = 0; arr = new T[length]; } template Set ::~Set(void) { delete [] arr; } template void Set::addVal(const T &value) { int i; T *temp; T tval; i = 0; while(tval = arr[i++]) { if(tval == value) return; } arr[pos] = value; pos++; //sort using insertion sort insertSort(); } template void Set::insertSort(void){ int i, j; T index; for (i=0; i < pos; i++){ index = arr[i]; j = i; while ((j > 0) && (arr[j-1] > index)){ arr[j] = arr[j-1]; j = j - 1; } arr[j] = index; } } template void Set::printVec(void){ int i; if(pos < 0){ cout << "There are no values in Vector!" << endl; }else{ for(i=0; i <= pos; i++){ cout << arr[i] << " "; } cout << endl; } } template int Set :: getLength(void){return length;} template int Set :: getPos(void){return pos;}