### Cant return int

At the end of the class It will not let me return an integer any help?

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798`` ``````#include #include using namespace std; //This class sorts arrays either ascending or descending template class Prob2Sort { private: int *index; //Index that is utilized in the sort public: Prob2Sort(){index=NULL;}; //Constructor ~Prob2Sort(){delete []index;}; //Destructor T * sortArray(const T*,int,bool); //Sorts a single column array T * sortArray(const T*,int,int,int,bool); //Sorts a 2 dimensional array }; template T* Prob2Sort::sortArray(const T* arry, int rows, int cols, int column, bool order) { // put into new array to sort and return T* a_ray = new T[(rows*cols) + 1]; for(int i=0;i a_ray[(i+1)*cols+column]) { cout << "ELEMENT 1 IS " << a_ray[i*cols+column] << endl; temp = arry[i*cols+column]; cout << "TEMP IS " << temp << endl; a_ray[i*cols+column] = a_ray[(i+1)*cols+column]; cout << "ELEMENT 1 NEW is " << a_ray[(i)*cols+column] << endl; cout << "ELEMENT 2 is " << a_ray[(i+1)*cols+column] << endl; a_ray[(i+1)*cols+column] = temp; cout << "ELEMENT 2 NEW is " << a_ray[(i+1)*cols+column] << endl; test = true; } } }while(test); return column ; } int main(){ cout<<"The start of Problem 2, the sorting problem"< rc; bool ascending=true; ifstream infile; infile.open("Problem2.txt",ios::in); char *ch2=new char[(4*17)+ 1]; char *ch2p=ch2; while(infile.get(*ch2)){ch2++;} infile.close(); cout<>column; char *zc=rc.sortArray(ch2p,4,17,column,ascending); for(int i=0;i<4;i++) { for(int j=0;j<17;j++) { cout<
You specify that the function should return T* not int. That's why it won't let you.
Topic archived. No new replies allowed.