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>
19 lines
243 B
C++
19 lines
243 B
C++
|
|
#ifndef SUBJECT_H
|
|
#define SUBJECT_H
|
|
|
|
class Observer;
|
|
|
|
#include <set>
|
|
|
|
class Subject {
|
|
public:
|
|
void attach(Observer* observer);
|
|
protected:
|
|
void notify();
|
|
private:
|
|
std::set<Observer*> m_observers;
|
|
};
|
|
|
|
#endif
|