Site Tools


list
Лист объектов
class Subject{
public:
  void attach(Observer* o){
    _observers->Append(o);
  };
  
  void detach(Observer* o){
    _observers->Remove(o);
  }
  
  void notify(){
    ListIterator<Observer*> i(_observers);
    for(i.First(); !i.IsDone(); i.Next()){
      i.CurrentItem()->Update();
    }
  }
private:
  List<Observer*> *_observers;
};

class Observer{
public:
  Observer(Subject* sub){
    sub->Attach(this);
  }
}
You could leave a comment if you were logged in.
list.txt · Last modified: 2013/02/25 19:14 by konovalov

Page Tools