July 2001
Beginner to intermediate
368 pages
6h 52m
English
class Customer { public: static void attach(Observer *o); static void detach(Observer *o); String getState(); private: Vector myObs; void notifyObs(); } Customer::attach(Observer *o){ myObs.addElement(o); } Customer::detach(Observer *o){ myObs.remove(o); } Customer::getState () { // have other methods that will // give the required information } Customer::notifyObs () { for (Enumeration e = myObs.elements(); e.hasMoreElements() ;) { ((Observer *) e)-> update(this); } } } class Observer { public: Observer(); void update(Customer *mycust)=0; // makes this abstract } Observer::Observer () { Customer.attach( this); } class AddrVerification : public Observer { public: AddrVerification(); ... |