1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #define _CRT_SECURE_NO_WARNINGS #include <iostream>
using namespace std;
int func(int a, int b) { cout << "func 111 " << endl;
return 0; }
typedef int(FUNC)(int, int);
typedef int(*FUNC_POINTER)(int, int);
void my_function(FUNC *fp) { fp(10, 20); }
void my_function2(FUNC_POINTER fp) { fp(10, 20); }
void my_function3(int(*fp)(int, int)) { cout << "1999 年写的架构" << endl; cout << "固定业务1" << endl; fp(10, 20); cout << "固定业务2" << endl; }
int my_new_function(int a, int b) { cout << a << b << endl; cout << "2015年实现的新业务" << endl;
return 0; }
int main(void) { FUNC * p = func; FUNC_POINTER p2 = func; int(*fp)(int, int) = func;
p(10, 20); (*p)(10, 20);
p2(10, 20); (*p2)(20, 20);
fp(10, 20);
cout << " -------- " << endl;
my_function3(my_new_function); return 0; }
|