#include #include using namespace std; //--------Observer---------------- class ITeacherListenner { public: virtual void onTecherComming(int value) = 0; }; class ZhangSan:public ITeacherListenner { public: void onTecherComming(int value) { stopCopyWork(value); } void stopCopyWork(int value) { cout<<"zhangsan stopCopyWork + "<::iterator it; for(it=listenners.begin();it!=listenners.end();it++) { if(*it == l) { listenners.remove(l); break; } } } void notify() { list::iterator it; for(it=listenners.begin();it!=listenners.end();it++) { (*it)->onTecherComming(mValue); } } void setValue(int value) { mValue = value; notify(); } private: list listenners; int mValue; }; //-----------main----------------- int main() { cout << "Hello World1-------------"<