The signature function cannot be typedef ed. Only function type. Therefore, it is fair to say:
typedef int INT_OPERATION(int a, int b);
and then forward declare a function of this type:
INT_OPERATION Add;
but , when it comes to defining the function you need to specify for the arguments, so the following expression is not valid
INT_OPERATION Add { }
(as soon as you put the set () after Add , you will declare a function that returns a simple function that is not valid with C ++)
About common types
The same procedure has similar limitations when using tools for general programming. You can declare the following typedef:
template<typename T> using INT_OPERATION = const T(T const, T const);
And then use it to declare a function (forward)
INT_OPERATION<int> add; int main() { std::cout << add(1, 2) << std::endl; return 0; }
but when it comes to defining it, you must be mandane
const int add(int const a, int const b) { return a + b; }
Demo
source share