#include #include "interface.h" class Subject { public: Subject(size_t state) : state(state) {} size_t getState() { return this->state; } void setState(size_t state) { this->state = state; notifyAllObservers(); } void attach(Observer *observer) { vector.push_back(observer); } void notifyAllObservers() { for(auto itor : vector) { itor->update(); } } private: std::vector vector; size_t state; };