#include <iostream>
void printA(int len)
{
std::cout << "HelloA World! " << std::endl;
}
void printB(int len)
{
std::cout << "HelloB World!" << std::endl;
}
void callback(int num, void(*print)(int) )
{
int i = 0;
for(; i < num; i++)
{
print(i);
}
std::cout << "Hello World!" << std::endl;
}
int main(void)
{
callback(10, printA);
callback(10, printB);
getchar();
return 0;
}
函数的回调
最新推荐文章于 2023-01-03 14:32:53 发布