I'm pretty new to STL and am trying to fill in for some code that creates a priority queue with the top of the queue always being the largest value of the queue. The question specifies not to include the functional header (i.e. no greater<>). So here's what I go for:
int main()
{
struct hi
{
bool operator () (double & a, double & b) const
{
return a > b;
}
};
priority_queue < double, vector<double>, hi > q;
//... other operations.
When I compile this is MSVC, everything goes well and I get the desire result when I call q.top() and print the top value. But when compiling this is ideOne or Eclipse with GCC, I get a compilation error about "invalid type declaration before ;". What am I doing wrong here?
Note: I was supposed to fill in a black inside the main function.