title: Coming from Java, C#, if C++ has no event handling, how does one catch when something happens?
body: <p>Java and C# differ in their respective event handling techniques. In Java you write interfaces or classes that your program can call. In C# it is done differently using events and delegates.</p>
  
  <p>Does C++ have some form of event handling?</p>
  
  <p>My understanding is in Java events are done like this:</p>
  
  <pre><code>class Class1
  {
       private ArrayList&lt;MyEventListener&gt; listeners;
  
       //Class stuff
  
       public void doEvent () {for(MyEventListener e : listeners) {e.eventHappened(args);}
  
       public void addToListeners(MyEventListener eventListener) {listeners.add(eventListener);
       public void removeFromListeners(MyEventListener eventListener) {listeners.add(eventListener);
       public interface MyEventListener
       {
            void eventHappend (Anything passable);
       } 
  }
  </code></pre>
  
  <p>I imagine C++ it could be done similiarly</p>
  
  <pre><code>Define new Class
  {
      Define Array (Java ArrayList/List) of the abstract class or interface below
  
      //Define other unrelated class stuff
  
      Define add to listeners function
  
      Define remove from listeners function
  
      Define inner interface (maybe a C++ abstract class would work instead as interfaces don't exist in C++) to act as event
  
             Define function in inner abstract event class to be the actual part of the code that represents the event
  
      Define call all listeners function
  }
  </code></pre>
  
  <p>Does this make sense? I honestly can not see how one could program anything without an event listener/handler system, I assume I am close.</p>
  
  <p>How have you dealt with events having come from another language?</p>