priortiy_queue<int,greater> pq aisa bhi to likh sakte hai
Doubt in priority queue extension
@utkarsh273,
Nope, we cannot, you can try, it will give compile error.
Because,
Link
As you can see, second and the third template parameters are default parameters, so you cannot just explicitly change the third default parameter, without also specifying the second default parameter.
E,g
int function(int a=1,int b=2,int c=3){
//Code
}
Here if you want to provide different value to a then function(5) is a valid call, But if you have to change only c’s value, function(5) will not be a right call, cause obviously, program will think that 5 has to be assigned to a.
For changing c, function(1,2,5) is a valid call.
Similarly with default parameters in priority_queue
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.