C++ Pointers to functions.

Posted by Andy Leman on Stack Overflow See other posts from Stack Overflow or by Andy Leman
Published on 2010-12-31T05:44:45Z Indexed on 2010/12/31 5:54 UTC
Read the original article Hit count: 204

Filed under:
using namespace std;

int addition (int a, int b)
{
    return (a+b);
}

int subtraction (int a, int b)
{
    return (a-b);
}
int operation (int x, int y, int (*functocall)(int,int))
{
    int g;
    g = (*functocall)(x,y);
    return(g);
}
int main()
{
    int m,n;
    int (*minus)(int,int) = subtraction;

    m = operation (7,5,addition);
    n = operation (20,m,minus);
    cout << n;
    return 0;
}

Can anybody explain this line for me

int (*minus)(int,int) = subtraction;

Thanks a lot!

© Stack Overflow or respective owner

Related posts about c++