1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| #include "observer.h" #include "subject.h"
int main(int argc, char *argv[]) { Service service; Subscriber subscriberA("Subscriber A"); Subscriber subscriberB("Subscriber B"); Subscriber subscriberC("Subscriber C");
service.registerObserver(&subscriberA); service.registerObserver(&subscriberB); service.registerObserver(&subscriberC); service.notify();
service.unregisterObserver(&subscriberC); service.notify();
return 0; }
|