GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Monday, February 28, 2011

Callback Function With Arguments

/**
 * Callback function is a function that passed as argument 
 * parameter. It's called as argument parameter.
 */

#include <iostream>

using namespace std;

void hello(int a){
    cout << a << endl;
}

// callback function
// function as argument parameter
void greeting(void (*func) (int)){
    int b = 45;   // initialization
    func(b);
}

int main(int argc, char *argv[]){
    // callback function
    greeting(hello);

    return 0;
}

Share/Bookmark

No comments:

Post a Comment