you used bool compare( int a,int b ) as a function but while passing in bubble_sort function use used it as
void bubble_sort(int a[ ], int n, bool(&cmp)(int a,int b)
how? why?
you used bool compare( int a,int b ) as a function but while passing in bubble_sort function use used it as
void bubble_sort(int a[ ], int n, bool(&cmp)(int a,int b)
how? why?
@345avamanverma
This is the syntax for passing reference to a function to another function
We passed reference of compare function so that sort function can use the custom comparator
If your doubt is resolved please mark it as closed