Esempio n. 1
0
int main() {
    ConcreteSubject * subject = new ConcreteSubject();
    subject->Attach(new ConcreteObserver(subject, "zhaohua"));
    subject->Attach(new ConcreteObserver(subject, "lichao"));

    subject->SetState("Doc Yang comes here !!!");
    subject->Notify();

    return 0;
}
Esempio n. 2
0
int main()
{
    ConcreteSubject product;
                    
    ConcObs shop1("Shop 1");
    ConcObs shop2("Shop 2");
    ConcObs shop2("Shop 3");

    product.Attach(&shop1);
    product.Attach(&shop2);
    product.Attach(&shop3);

    product.ChangePrice(23.0f);
    product.Detach(&shop2);            
    product.ChangePrice(26.0f);

    return 0;
}