counterobserver.cpp

来自「financal instrument pricing using c」· C++ 代码 · 共 23 行

CPP
23
字号
// CounterObserver.cpp
//
// (C) Datasim Education BV 2001

#include "CounterObserver.hpp"
#include <iostream>

CounterObserver::CounterObserver(Counter& obj)
{
	obj.AddObserver(this);
}
// Method is called when the obeservable object has a change in its state
void CounterObserver::Update(Observable* obj)
{
	Counter* pCounter = dynamic_cast<Counter*>(obj);
	if(pCounter != NULL)
		std::cout << "Observer address : " << this << " Counter has changed : " << pCounter->GetCounter() << std::endl;
	else
		std::cout << "Unknown observable" << std ::endl;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?