fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Button
  6. {
  7. private:
  8. void (*f_m)();
  9. public:
  10. Button(void (*f)()) : f_m(f) {}
  11. ~Button(){}
  12. void operator() () { f_m(); } // meke button a callable (i.e. button() )
  13. };
  14.  
  15. class Game_Events
  16. {
  17. public:
  18. Button* button;
  19. Game_Events()
  20. {
  21. button = new Button(&Close);
  22. }
  23. ~Game_Events(){}
  24. static void Close(){ cout<<"general boum"<<endl;} //I need to pass this function for call it on the other side
  25. };
  26.  
  27. int main() {
  28. Game_Events e;
  29. (*e.button)();
  30. return 0;
  31. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
general boum