Assume the following code:
class Event {
public:
virtual void execute() {
std::cout << "Event executed.";
}
}
class SubEvent : public Event {
void execute() {
std::cout << "SubEvent executed.";
}
}
void executeEvent(Event e) {
e.execute();
}
int main(int argc, char ** argv) {
SubEvent se;
executeEvent(se);
}
When executed, the program outputs "Event executed.", but I want to execute SubEvent. How can I do that?