std::binary_function - no match for call?

Posted by Venkat Shiva on Stack Overflow See other posts from Stack Overflow or by Venkat Shiva
Published on 2010-04-02T17:02:43Z Indexed on 2010/04/02 17:13 UTC
Read the original article Hit count: 430

Filed under:
|

Hi, this is my code:

#include <iostream>
#include <functional>

using namespace std;

int main() {
  binary_function<double, double, double> operations[] = {
    plus<double>(), minus<double>(), multiplies<double>(), divides<double>() 
  };
  double a, b;
  int choice;
  cout << "Enter two numbers" << endl;
  cin >> a >> b;
  cout << "Enter opcode: 0-Add 1-Subtract 2-Multiply 3-Divide" << endl;
  cin >> choice;
  cout << operations[choice](a, b) << endl;
}

and the error I am getting is:

Calcy.cpp: In function ‘int main()’:
Calcy.cpp:17: error: no match for call to ‘(std::binary_function<double, double, double>) (double&, double&)’

Can anyone explain why I am getting this error and how to get rid of it?

© Stack Overflow or respective owner

Related posts about c++

Related posts about stl