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EseS7r6GjPC9wPgo8cD48c3Ryb25nPsvEoaJDJiM0MzsmIzQzO8q1z9Y8L3N0cm9uZz48L3A+CjxwPqOoMaOpU3ViamVjdC5oPC9wPgo8cD48L3A+CjxwcmUgY2xhc3M9"brush:java;">#ifndef SUBJECT_H
#define SUBJECT_H
#include £¨2£©Subject.cpp £¨3£©Observer.h £¨4£©Observer.cpp £¨5£©Client.cpp
class Observer;
//Subject£¬³éÏó֪ͨÕß»òÕßÖ÷Ìâ
class Subject
{
protected:
std::string SubjectState;
public:
virtual void Attach(Observer* observer)=0;
virtual void Detach(Observer* observer)=0;
virtual void Notify()=0;
std::string GetSubjectState();
void SetSubjectState(std::string state);
};
//ConcreteSubject£¬¾ßÌå֪ͨÕß»òÕß¾ßÌåÖ÷Ìâ¡£
class Boss:public Subject
{
private:
std::list
#include "Subject.h"
#include "Observer.h"
std::string Subject::GetSubjectState()
{
return SubjectState;
}
void Subject::SetSubjectState(std::string state)
{
this->SubjectState=state;
}
void Boss::Attach(Observer* observer)
{
observers.push_back(observer);
}
void Boss::Detach(Observer* observer)
{
std::list
#ifndef OBSERVER_H
#define OBSERVER_H
#include
#include
#include "Observer.h"
Observer::Observer(){}
Observer::Observer(std::string name,Subject* sub)
{
this->name=name;
this->sub=sub;
}
void Observer::Update()
{
std::cout<<"Observer.Update()"<
#include "Observer.h"
#include
£¨6£©ÔËÐнØͼ