1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
typedef int ( *pf )( int, int );
int add( int x, int y ) { return ( x + y ); }
int multiply( int x, int y ) { return ( x * y ); }
int substruct( int x, int y ) { return ( x - y ); }
int divide( int x, int y ) { return ( x / y ); }
void execute( pf func, int x, int y )
{
std::cout << func( x, y ) << std::endl;
}
int main()
{
execute( add, 10, 10 );
execute( multiply, 10, 10 );
execute( substruct, 10, 10 );
execute( divide, 10, 10 );
return ( 0 );
}
|