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