c++ - No matching function for 'sort(int [2000], int)'| while sorting array -
i wanted sort array in simple way error below. how deal that?
**no matching function call 'sort(int [2000], int)'|**
#include <iostream> #include <algorithm> using namespace std; int main(){ int v[2000]; std::sort(v, 2000); cout << "hello world!" << endl; return 0; }
the correct statement is:
std::sort(v, v + 2000);
the function takes 2 iterators, beginning , end of range sort. pointer random-access iterator, can used function expects one. in case, v + 2000
points past end of array , correctly stands end of range.
Comments
Post a Comment