Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. int caller(int (*callback)(void *arg), void * arg = NULL) {
  2. return callback(arg);
  3. }
  4.  
  5. int main(int argc, char **argv) {
  6.  
  7. const char *str = "world";
  8. caller([&](void *arg) {
  9. printf("hello %sn", str);
  10. return 0;
  11. }, NULL);
  12.  
  13. return 0;
  14. }
  15.  
  16. printf("hello %sn", str)
  17.  
  18. int caller(std::function<int(void*)> callback, void * arg = NULL) {
  19. return callback(arg);
  20. }
  21.  
  22. caller([](void *arg) {
  23. printf("hello %sn", (const char*)arg);
  24. return 0;
  25. }, str);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement