#include <iostream>
#include <string>
using namespace std;
class WithNotification {
public:
virtual void notify()=0;
};
class Robot : public virtual WithNotification {
private:
string name;
public:
Robot(const string& n) : name(n) {}
virtual void notify() {cout << name << " has been notified" << endl; }
};
class Task {
private:
WithNotification& onFinished;
public:
Task(WithNotification& f) : onFinished(f) {}
void run() {
cout << "The task is running" << endl;
onFinished.notify();
}
};
int main() {
Robot r1("Quick");
Robot r2("Brown");
Task t1(r1);
Task t2(r2);
t1.run();
t2.run();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgV2l0aE5vdGlmaWNhdGlvbiB7CnB1YmxpYzoKICAgIHZpcnR1YWwgdm9pZCBub3RpZnkoKT0wOwp9OwoKY2xhc3MgUm9ib3QgOiBwdWJsaWMgdmlydHVhbCBXaXRoTm90aWZpY2F0aW9uIHsKcHJpdmF0ZToKICAgIHN0cmluZyBuYW1lOwpwdWJsaWM6CiAgICBSb2JvdChjb25zdCBzdHJpbmcmIG4pIDogbmFtZShuKSB7fQogICAgdmlydHVhbCB2b2lkIG5vdGlmeSgpIHtjb3V0IDw8IG5hbWUgPDwgIiBoYXMgYmVlbiBub3RpZmllZCIgPDwgZW5kbDsgfQp9OwoKY2xhc3MgVGFzayB7CnByaXZhdGU6CiAgICBXaXRoTm90aWZpY2F0aW9uJiBvbkZpbmlzaGVkOwpwdWJsaWM6CiAgICBUYXNrKFdpdGhOb3RpZmljYXRpb24mIGYpIDogb25GaW5pc2hlZChmKSB7fQogICAgdm9pZCBydW4oKSB7CiAgICAgICAgY291dCA8PCAiVGhlIHRhc2sgaXMgcnVubmluZyIgPDwgZW5kbDsKICAgICAgICBvbkZpbmlzaGVkLm5vdGlmeSgpOwogICAgfQp9OwoKaW50IG1haW4oKSB7CglSb2JvdCByMSgiUXVpY2siKTsKCVJvYm90IHIyKCJCcm93biIpOwogICAgICAgIFRhc2sgdDEocjEpOwogICAgICAgIFRhc2sgdDIocjIpOwogICAgICAgIHQxLnJ1bigpOwogICAgICAgIHQyLnJ1bigpOwp9