I have the following Classes:
typedef void (*ScriptFunction)(void);
typedef std::unordered_map<std::string, std::vector<ScriptFunction>> Script_map;
class EventManager
{
public:
Script_map subscriptions;
void subscribe(std::string event_type, ScriptFunction handler);
void publish(std::string event);
};
class DataStorage
{
std::vector<std::string> data;
public:
EventManager &em;
DataStorage(EventManager& em);
void load(std::string);
void produce_words();
};
DataStorage::DataStorage(EventManager& em) : em(em) {
this->em.subscribe("load", this->load);
};
I want to be able to pass DataStorage::load to EventManager::subscribe so i can call it later on. How can i achieve this in c++?