本文整理汇总了C++中WeatherData::removeObserver方法的典型用法代码示例。如果您正苦于以下问题:C++ WeatherData::removeObserver方法的具体用法?C++ WeatherData::removeObserver怎么用?C++ WeatherData::removeObserver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeatherData
的用法示例。
在下文中一共展示了WeatherData::removeObserver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
WeatherData *weatherData = new WeatherData();
CurrentConditionsDisplay* currentDisplay =
new CurrentConditionsDisplay(weatherData);
StatisticsDisplay* statisticsDisplay = new StatisticsDisplay(weatherData);
ForecastDisplay* forecastDisplay = new ForecastDisplay(weatherData);
weatherData->setMeasurements(80, 65, 30.4f);
cout << endl;
weatherData->setMeasurements(82, 70, 29.2f);
cout << endl;
weatherData->removeObserver(currentDisplay);
weatherData->removeObserver(currentDisplay);
weatherData->removeObserver(currentDisplay);
weatherData->removeObserver(currentDisplay);
weatherData->setMeasurements(78, 90, 29.2f);
cout << endl;
delete weatherData;
delete currentDisplay;
delete statisticsDisplay;
delete forecastDisplay;
return 0;
}
示例2: main
int main()
{
Subject *s;
WeatherData weather;
s = &weather;
CurrentConditionDisplay currentDisplay;
CurrentConditionDisplay currentDisplay2;
ForcastConditionDisplay forcastDisplay;
weather.registerObserver(¤tDisplay);
weather.registerObserver(¤tDisplay2);
weather.registerObserver(&forcastDisplay);
weather.setMeasurements(80,62,30.4);
weather.removeObserver(¤tDisplay2);
weather.setMeasurements(80,62,30.4);
return 0;
}