I have one base class that contains map for function pointers like this
typedef void (BaseClass::*event_t)(); class BaseClass { protected: std::map<std::string, event_t> events; public:
Handling this works as a prefect, but now I want to make BaseClass abstract base class to extract from this:
class SpecificClass : public BaseClass { public: void onBar() {
Although I can access the map from SpecificClass , I cannot add onBar because the event_t type event_t defined only for BaseClass ! Is there a possibility (possibly with templates?) Which does not lead to event_t definition for each class that I will use ...
(No need to use templates! Any good / suitable approach would be nice.)
Additional reference information:
All this for textual RPG. My base class could be called Location and specify any place, for example. CivicCenter . Each Location object subscribes to my EventSystem , which notifies all the necessary objects when I fire the event. Therefore, I want to save on the map some pointers to private functions that contain actions with their "name", for example, onSetOnFire (xD) as a key.
Christian Ivicevic
source share