I am using std::sort
in main function, but when use in a function, it is giving errors.
int main()
{
int arr[5] = {1,4,2,3,5};
std::sort(std::begin(arr), std::end(arr));
...
}
above code works fine. but when I do
void my_sort(int a[], int length)
{
std::sort(std::begin(a), std::end(a));
}
int main()
{
int arr[5] = {1,4,2,3,5};
my_sort(arr, 5);
}
It gives error that
error: no matching function for call to ‘begin(int*&)’
std::sort(std::begin(a), std::end(a));
^
Why is it so ? I am using g++
Aucun commentaire:
Enregistrer un commentaire