Hello, explain on fingers what it means:

int (*fp) (int a); 

What is being done here? Can be more? Thank!

    1 answer 1

    A function pointer variable named fp. The function accepts an input parameter of type int and also returns an int.

     int foo(int a) { return ++a; } ..... int (*fp)(int a); fp = &foo; fp(5); // вызов функции foo через указатель на неё. 
    • And if you need to overload the function? If we pass the 2nd variables to func, it will look like this: int (* fp) (int a, int b); ? - Alerr
    • No, if it is necessary to call one function in one place, and in another another through the same pointer. - fogbit
    • @fogbit, when you call fp () you need a parameter - insolor
    • one
      By the way, you can just write fp = foo; - skegg