The following example, taken from here , compiles and runs correctly for me in Visual Studio 2012:
// greater example #include <iostream> // std::cout #include <functional> // std::greater #include <algorithm> // std::sort int main () { int numbers[]={20,40,50,10,30}; std::sort (numbers, numbers+5, std::greater<int>()); for (int i=0; i<5; i++) std::cout << numbers[i] << ' '; std::cout << '\n'; return 0; }
Output:
50 40 30 20 10
According to the comments on the question and the example above, you need to include <functional> , not <functional.h> .
source share