In some methods like sort(), we use greater< int>() for comparison whereas we pass greater < int> only as argument in priority queue and not greater< int>(), what’s the difference between the two?
Difference between greater<int> and greater<int>()
Hey @rishit517 We use greater < int> In
priority_queue<int,vector<int>,greater<int> >
In this declaration the type template argument greater<int>
corresponds to the type of a structure.
Whereas when we use for sort function the type template argument greater<int>()
corresponds to the type of a function that has no parameters and has the return type greater<int>
. So one is function that’s used in sort and other is the instruction of what a data structure would look like.