main() { MyObservable* observable = MyObservable::GetInstance(); MyClass1* obj = new MyClass1(); MyClass2* obj1 = new MyClass2(); observable->Trigger(); }
int main() { MyObservable* observable = MyObservable::GetInstance(); MyClass* obj = new MyClass(); observable->Trigger(); cout<<"in break \n"; MyClass* obj1 = new MyClass(); observable->Trigger(); cout<<"in break \n"; MyClass* obj2 = new MyClass(); observable->Trigger(); return 0; }
~MyClass() { observable->RemoveObserver(*this); }
MyClass() { observable = MyObservable::GetInstance(); observable->AddObserver(*this); }
int main() { MyObservable* observable = MyObservable::GetInstance(); MyClass *obj = new MyClass(); observable->Trigger(); }