void bubble_sort(int a[],int n,bool (&cmp)(int a,int b))
how is a,b variable getting initialized?
Comparators In STL
Hello @samardeepif you have seen the video then it is just the different syntax which is used like this.
&cmp is the name of the function and we can actually use anyname like it.’&’ is used to complete the syntax.
but if you will see the video then there we are passing the original comparator as a parameter.
this parameter is accepting the function which will return boolean values and which itself takes two integers as parameters.i.e ‘a’ and ‘b’ .
Happy Learning!!
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.