feat(cmat): implement Ex41 observer pattern
Refactor the Pelican crossing exercise to use the Observer pattern: Pelican acts as Subject and each Pole observes it, replacing direct calls through the owned Pole pointer. Co-authored-by: Qwen 3.8 27B <qwen3.8_27b-q3_k_xl@lmstudio.local>
This commit is contained in:
+3
-3
@@ -8,11 +8,11 @@ class Observer;
|
||||
|
||||
class Subject {
|
||||
public:
|
||||
// TODO: Declare the attach() function that adds an Observer to the set
|
||||
void attach(Observer* observer);
|
||||
protected:
|
||||
// TODO: Declare the notify() function that calls all the update functions
|
||||
void notify();
|
||||
private:
|
||||
// TODO: Define a set of Observer pointers
|
||||
std::set<Observer*> m_observers;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user