c++ - What does "cannot Convert vector<int>* to int" mean? -
i have error:
error 1 error c2664: 'int practicemergesort(int,int,std::vector>)' : cannot convert argument 1 'std::vector> *' 'int'
i have no idea may cause of error or error telling me.
edit:
function prototypes int practicemergesort(int, int, vector<int>); int practicemerge(vector<int>, int, int, int); int main() { int numofitems; srand(int(time(0))); // initialize random number generator printf("algorithm comparison\n\n"); printf("selection sort\n"); //selectionsort(); practiceselectionsort(); // functioning version //------------------------------------------------------------------ cout << "\nmerge sort\n"; cout << "enter number of items sorted: "; cin >> numofitems; vector<int> mergearray(numofitems); cout << "value of numofitems: " << numofitems << "\n"; cout << "array values: \n"; (int x = 0; x < numofitems; x++) { mergearray[x] = rand(); cout << mergearray[x] << "\n"; } practicemergesort(&mergearray, 0, numofitems); //------------------------------------------------------------------ // testing of array filler //printf("\narray filler\n"); //arrayfiller(); cout << "\n\n"; system("pause"); return 0; } int practicemergesort(vector<int> mergearray[], int low, int high) { if (low < high) { int mid = (high + low) / 2; practicemergesort(mergearray, low, mid); practicemergesort(mergearray, mid + 1, high); practicemerge(mergearray, low, mid, high); } return 0; } int practicemerge(vector<int> mergearray[], int low, int mid, int high) { vector<int> b[10000]; int = low, j = mid + 1, k = 0; while (i <= mid && j <= high) { if (mergearray[i] <= mergearray[j]) b[k++] = mergearray[i++]; else b[k++] = mergearray[j++]; } while (i <= mid) b[k++] = mergearray[i++]; while (j <= high) b[k++] = mergearray[j++]; k--; while (k >= 0) { mergearray[low + k] = b[k]; k--; } return 0; }
your problem function prototypes don't match actual function definitions:
//function prototypes int practicemergesort(int, int, vector<int>); int practicemerge(vector<int>, int, int, int); // functions int practicemergesort(vector<int> mergearray[], int low, int high) { //... } int practicemerge(vector<int> mergearray[], int low, int mid, int high) { //... }
change prototypes to:
int practicemergesort(vector<int> mergearray[], int low, int high); int practicemerge(vector<int> mergearray[], int low, int mid, int high);
or if want keep using prototypes unnamed arguments:
int practicemergesort(vector<int> [], int, int); int practicemerge(vector<int> [], int, int, int);
that make compile.
Comments
Post a Comment