Skip to content

Instantly share code, notes, and snippets.

@soachishti
Last active October 10, 2015 10:03
Show Gist options
  • Save soachishti/d521208e9191a6b9cfd9 to your computer and use it in GitHub Desktop.
Save soachishti/d521208e9191a6b9cfd9 to your computer and use it in GitHub Desktop.
Callback C++
// Source: http://en.wikipedia.org/wiki/Callback_(computer_programming)
#include <iostream>
#include <cstdlib>
using namespace std;
void callback(int (*f)(int i , int b)) {
f(10,20);
//cout << f(10,20);
}
int meaningOfLife(int i , int b) {
cout << "Hello" << "This is me12321";
cout << i << b;
return 42;
}
int main(void) {
callback(&meaningOfLife);
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment