Events in C++ -
i'm not sure how online... think might called different in c++
i want have simple event system, somthing like
event mycustomevent; mycustomevent.subscribe( void myhandler(string) ); mycustomevent.fire("a custom argument"); // myhandler prints out string passed in first argument event mynewcustomevent; mynewcustomevent.subscribe( void mynewhandler(int) ); mynewcustomevent.fire(10); // myhandler prints 10
i can pretty simple class -- when want have event passes different type or amount of arguments subscriber have write, , define entirely new event class.. figure there has library, or maybe native in visual c++ 2008 work similar this. it's basicly implementation of observer pattern, can't impossible in c++
this makes me appreciate how nice in javascript not have worry arguments passing.
tell me if stupid question.
i use sigslot purpose.
Comments
Post a Comment