title: Passing a subclass object to a function that takes superclass object
body: <p>Assume the following code:</p>
  
  <pre><code>class Event {
  public:
      virtual void execute() {
          std::cout &lt;&lt; "Event executed.";
      }
  }
  
  class SubEvent : public Event {
      void execute() {
          std::cout &lt;&lt; "SubEvent executed.";
      }
  }
  
  void executeEvent(Event e) {
      e.execute();
  }
  
  int main(int argc, char ** argv) {
      SubEvent se;
      executeEvent(se);
  }
  </code></pre>
  
  <p>When executed, the program outputs "Event executed.", but I want to execute SubEvent. How can I do that?</p>