文章目录

http://blog.csdn.net/callmeback/article/details/4242260/

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
#include <stdio.h>
#include<iostream>
void printWelcome(int len)
{
printf("欢迎欢迎 -- %d/n", len);
}

void printGoodbye(int len)
{
printf("送客送客 -- %d/n", len);
}

void callback(int times, void(*print)(int))
{
int i;
for (i = 0; i < times; ++i)
{
print(i);
}
printf("/n我不知道你是迎客还是送客!/n/n");
}
void main(void)
{
callback(10, printWelcome);


std::cout << std::endl<< "--------------------------------------------------------------------------------------------" << std::endl;




callback(10, printGoodbye);
std::cout << std::endl << "--------------------------------------------------------------------------------------------" << std::endl;
printWelcome(5);
}
  1. 注册回调函数
    https://blog.csdn.net/mrailence/article/details/52251201
  1. 回调函数demo
  1. 回调函数demo2

  2. 关于回调函数

文章目录