Do I need to pass the comparator function to the function concerned( like in this case void bubblesort(int a[],int n,bool (&compare)) )
i can also call the function directly

Do I need to pass the comparator function to the function concerned( like in this case void bubblesort(int a[],int n,bool (&compare)) )
i can also call the function directly

@singhayush7397 in this case, abc() is a function you made, and cmp is a comparator you made, and you ensured that both are visible to each other, and also ensured that cmp is the comparator being used inside that function, so there is no need to pass the address of the comparator function.
But when we are using STL functions like sort() we need to pass the address of our comparator to ENSURE that only that comparator is used. Else how would the function know which comparator to use?
I hope you understood my point.
Dont forget to mark your doubt as resolved!
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.