int main()
{
    ConcreteSubject* s = new ConcreteSubject(100);
    s->attach(new ConcreteObserver("20160701",s));
    s->attach(new ConcreteObserver("20160705",s));
    s->setState(200);
    s->notify();
    return 0;
}
Пример #2
0
int main()
{
	// Das Objekt h�lt alle Daten (=notfier = subject) 
	ConcreteSubject* subj = new ConcreteSubject();

	ObserverInterface* obs1 = new ConcreteObserver(subj, "A");
	ObserverInterface* obs2 = new ConcreteObserver(subj, "B");

	// Observer(=views) an Subjekt anh�ngen (attachen) 
	subj->attach(obs1);
	subj->attach(obs2);

	// Daten �ndern und Observer informieren (notify) 
	subj->setData("TestData");
	subj->notify();

	return 0;
}