Skip to content

Instantly share code, notes, and snippets.

@derofim
Created August 14, 2015 08:02
Show Gist options
  • Select an option

  • Save derofim/cd8e0ec7126d3e47df71 to your computer and use it in GitHub Desktop.

Select an option

Save derofim/cd8e0ec7126d3e47df71 to your computer and use it in GitHub Desktop.
#include <iostream>
int add ( int a, int b ) { return ( a + b ); }
int sub ( int a, int b ) { return ( a - b ); }
int main()
{
using namespace std;
int ( *pf ) ( int, int ) = add;
cout << pf ( 3, 2 ) << endl; // Вывод: 5
cout << pf ( 4, 5 ) << endl; // Вывод: 9
pf = sub;
cout << pf ( 3, 2 ) << endl; // Вывод: 1
cout << pf ( 4, 5 ) << endl; // Вывод: -1
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment