int main(int argc, char* argv[]) { Boss* b = new Boss("胡汉三回来了"); StockObserver* so = new StockObserver("张博",b); NBAObserver* no = new NBAObserver("赵书淇",b); b->Attach(so); b->Attach(no); b->Notify(); cin.ignore(); return 0; }
int main(int argc, char const *argv[]) { Boss* huhansan = new Boss(); StockObserver* tongshi1 = new StockObserver("aaa",huhansan); StockObserver* tongshi2 = new StockObserver("bbb",huhansan); huhansan->Attach(tongshi1); huhansan->Attach(tongshi2); huhansan->Detach(tongshi1); huhansan->setSubjectState("我胡汉三回来了"); huhansan->Notify(); return 0; }