Why such strange behaviour while outputting the difference in sizes of two queues. When i am storing them in a diff variable its showing right answer, while just outputting the difference gives wrong answer.
#include<bits/stdc++.h>
using namespace std;
int main()
{
priority_queue<int , vector<int> , greater<int> > pmin;
priority_queue<int , vector<int> >pmax;
pmin.push(5);
pmin.push(9);
pmin.push(10);
pmax.push(1);
cout << pmax.size() - pmin.size() << endl;
int diff = pmax.size() - pmin.size();
cout << diff <<endl;
return 0 ;
}
**** Since downvotes doesn't affects me as most of them know why, but I think this is a very good question whom most of have no idea about the flaw in this. So it would be good if some good answers known to other people.