• 大小: 2.48KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-02-01
  • 标签: 设计模式  模式  设计  

资源简介

观察者模式

资源截图

代码片段和文件信息

#include 

#include “Subject.h“
#include “Observer.h“

#include “WeatherData.h“
#include “CurrentConditionsDisplay.h“
#include “TemperatureOnlyDisplay.h“

int main()
{
weather::WeatherData wd;
weather::CurrentConditionsDisplay ccd = weather::CurrentConditionsDisplay(&wd);
weather::TemperatureOnlyDisplay tod = weather::TemperatureOnlyDisplay(&wd);


wd.setMeasurement(3 2 1);
wd.removeObserver(&tod);
wd.setMeasurement(4 5 6);

    return 0;
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        906  2015-05-25 18:49  WeatherData\CurrentConditionsDisplay.h

     文件        167  2015-05-25 18:49  WeatherData\DisplayElement.h

     文件        469  2015-05-25 18:49  WeatherData\main.cpp

     文件         25  2015-05-25 18:49  WeatherData\Makefile

     文件        149  2015-05-25 18:49  WeatherData\Observer.h

     文件        279  2015-05-25 18:49  WeatherData\Subject.h

     文件        722  2015-05-25 18:49  WeatherData\TemperatureOnlyDisplay.h

     文件       1235  2015-05-25 18:49  WeatherData\WeatherData.h

     目录          0  2018-09-24 09:35  WeatherData

----------- ---------  ---------- -----  ----

                 3952                    9


评论

共有 条评论