binary function compile error

Hi,

I wrote a binary function based on existing template:
1
2
3
4
template <class T> struct percentage : binary_function <T,T,double> {
  double operator() (const T& x, const T& y) const
    {return x*1.0/(x+y);}
};

I call it in form of percentage<int>() When I compile, it's indicated:
error C2143: syntax error : missing ',' before '<'
I use VC 2012.

I am confused. Could anyone please tell me where is the error? Thanks!
At what line do you get this error on?
the first line of the template. Do I need a special header to compile it?
Last edited on
You will need:

1
2
3
#include <algorithm>

using namespace std;


To use the binary_function
std::binary_function is defined in the <functional> header.
Thanks for the replies. I added std:: and that works. Just forgot this thing... Thanks! :)
Topic archived. No new replies allowed.