#include <iostream>
#include <vector>
using namespace std;
struct Listener {
virtual void callback() = 0;
};
struct Listener1 : public Listener{
void callback() override {
cout << "listener1" << endl;
}
};
struct Processor {
vector<Listener*> listeners;
void notify() {
for(auto &listener : listeners) {
listener->callback();
}
}
};
int main() {
Listener1 listener1;
Processor processor;
processor.listeners.push_back(&listener1);
processor.notify();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IExpc3RlbmVyIHsKICB2aXJ0dWFsIHZvaWQgY2FsbGJhY2soKSA9IDA7Cn07CgpzdHJ1Y3QgTGlzdGVuZXIxIDogcHVibGljIExpc3RlbmVyewogIHZvaWQgY2FsbGJhY2soKSBvdmVycmlkZSB7CiAgCWNvdXQgPDwgImxpc3RlbmVyMSIgPDwgZW5kbDsKICB9Cn07CgpzdHJ1Y3QgUHJvY2Vzc29yIHsKICB2ZWN0b3I8TGlzdGVuZXIqPiBsaXN0ZW5lcnM7CiAgCiAgdm9pZCBub3RpZnkoKSB7CiAgICBmb3IoYXV0byAmbGlzdGVuZXIgOiBsaXN0ZW5lcnMpIHsKICAgIAlsaXN0ZW5lci0+Y2FsbGJhY2soKTsKICAgIH0KICB9Cn07CgppbnQgbWFpbigpIHsKCUxpc3RlbmVyMSBsaXN0ZW5lcjE7CgkKCVByb2Nlc3NvciBwcm9jZXNzb3I7CgkKCXByb2Nlc3Nvci5saXN0ZW5lcnMucHVzaF9iYWNrKCZsaXN0ZW5lcjEpOwoJCglwcm9jZXNzb3Iubm90aWZ5KCk7CgkKCXJldHVybiAwOwp9