Observer Pattern1 Observer pattern Observer pattern 1.소스 #include #include using namespace std; class Subject { // 1. "independent" functionality vector views; // 3. Coupled only to "interface" int value; public: void attach(Observer *obs) { views.push_back(obs); } void setVal(int val) { value = val; notify(); } int getVal() { return value; } void notify(); }; class Observer { // 2. "dependent" functionality .. 2016. 7. 14. 이전 1 다음