A typedef of function type may be used to declare a function but shall not be used to define a function
So your code should look like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <stdio.h>
int main (int argc, char * argv)
{
typedefint multiply(int arg1, int arg2);
multiply mult_function_1;
printf( "%d\n", mult_function_1( 2, 3 ) );
return 0;
}
int mult_function_1( int x, int y )
{
// for example
return ( x * y );
}
typedef is useful for simple variable naming. It's also useful for renaming iterators. I can't recommend using it for functions/methods. That is just making whoever is reading the code more confused.
#include <cstdio>
int mult_function_1( int x, int y );
typedefint (*func)(int, int); // func is a function pointer to a function that accepts two ints and returns an int
int main (int argc, char * argv)
{
func multiply = mult_function_1;
printf( "%d\n", multiply( 2, 3 ) );
return 0;
}
int mult_function_1( int x, int y )
{
// for example
return ( x * y );
}