GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Tuesday, March 1, 2011

Callback Function

#include <iostream>

/**
 * 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.
 */

using namespace std;

void hello(){
    int i=3;
    cout << i << endl;
}

void display(void(*func)(void)){
    func();
}

int main(int argc, char *argv[]){

    display(hello);

}

Share/Bookmark

No comments:

Post a Comment