rendered paste bodytemplate <class T>class Set { private: T *arr; int length; int pos; public: Set(void); ~Set(void); void addVal(const T&); void printVec(void); void insertSort(void); Set<T> unionSet(Set<T>); int getLength(); int getPos();};template <class T>Set <T>::Set(void) { length = 50; pos = 0; arr = new T[length];}template <class T>Set <T>::~Set(void) { delete [] arr;}template <class T>void Set<T>::addVal(const T &value) { int i; T *temp; T tval; /*//Resize as needed if(pos == length-1){ temp = new T[length+10]; for(i=0; i<length-1; i++){ temp[i]=arr[i]; } arr = temp; }*/ i = 0; while(tval = arr[i++]) { if(tval == value) return; } arr[pos] = value; pos++; //sort using insertion sort insertSort();}template <class T>void Set<T>::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 <class T>void Set<T>::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 <class T>Set<T> Set<T> :: unionSet(Set<T> x){ Set<T> *temp = new Set<T>(); temp = x; for(i=0; i < pos; i++){ temp->addVal(arr[i]); } return temp;}template <class T>int Set<T> :: getLength(void){return length;}template <class T>int Set<T> :: getPos(void){return pos;}