#include <iostream>
using namespace std;
void hello(int c){
cout << c << endl; // print out 45
}
void display(void(*func)(int)){
int def = 45;
func(def);
}
int main(int argc, char *argv[]){
display(hello);
}
/**
* Callback function need two function:
* 1. caller function - display();
* 2. called function - hello();
*
* Caller function just a function that has task to call
* the another function while the called function is
* what the function we define and we write.
*
* parameter supplied by the program or api. not you as programmer
*
*/
using namespace std;
/**
* This function is like main entry function
*/void hello(int c){
cout << c << endl; // print out 45
}
void display(void(*func)(int)){
int def = 45;
func(def);
}
int main(int argc, char *argv[]){
display(hello);
}
No comments:
Post a Comment