TAILIEUCHUNG - Thinking in Cplus plus (P28)

Tham khảo tài liệu 'thinking in cplus plus (p28)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | virtual void update Observable o Argument arg 0 endif OBSERVER_H Since Observer interacts with Observable in this approach Observable must be declared first. In addition the Argument class is empty and only acts as a base class for any type of argument you wish to pass during an update. If you want you can simply pass the extra argument as a void you ll have to downcast in either case but some folks find void objectionable. Observer is an interface class that only has one member function update . This function is called by the object that s being observed when that object decides its time to update all it s observers. The arguments are optional you could have an update with no arguments and that would still fit the observer pattern however this is more general - it allows the observed object to pass the object that caused the update since an Observer may be registered with more than one observed object and any extra information if that s helpful rather than forcing the Observer object to hunt around to see who is updating and to fetch any other information it needs. The observed object that decides when and how to do the updating will be called the Observable C09 The Observable class ifndef OBSERVABLE_H define OBSERVABLE_H include include set class Observable bool changed std set Observer observers protected virtual void setChanged changed true virtual void clearChanged changed false public virtual void addObserver Observer o o virtual void deleteObserver Observer o o virtual void deleteObservers virtual int countObservers Chapter 16 Design Patterns 451 return virtual bool hasChanged return changed If this object has changed notify all of its observers virtual void notifyObservers Argument arg 0 if hasChanged return clearChanged Not changed anymore std set Observer iterator it for it it it it - update this arg endif OBSERVABLE_H Again the design .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.