Callbacks & Events

Theory

Event manager system

Report a typo

Develop a basic event manager system in C++. Implement a class `EventManager` that allows registering callback functions to named events and triggering those events.

To implement the class, you need to describe two public methods:

subscribe(){}
void emit(){}

and one a private field:

map<string, vector<std::function<void()>>> handlers;

Note. Feel free to refer to the theory to better understand what and how you need to implement this class.

Sample Input 1:

Sample Output 1:

Event A triggered
Event B triggered
Event B triggered
Write a program in C++





Create a free account to access the full topic