#include <iostream>
class Worker
{
public:
virtual ~Worker() = default;
virtual void work() const = 0;
};
class Employer
{
public:
void askForWork(Worker const &w)
{
w.work();
}
};
int main() {
Employer e;
typedef struct : Worker {
void work() const override
{
std::cout << "I'm working\n";
}
} LocalWorkerT;
struct : Worker {
void work() const override
{
std::cout << "I'm working too\n";
}
} LocalWorker;
e.askForWork(LocalWorkerT {});
e.askForWork(LocalWorker);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgV29ya2VyCnsKcHVibGljOgogIHZpcnR1YWwgfldvcmtlcigpID0gZGVmYXVsdDsKICB2aXJ0dWFsIHZvaWQgd29yaygpIGNvbnN0ID0gMDsKfTsKCmNsYXNzIEVtcGxveWVyCnsKcHVibGljOgogIHZvaWQgYXNrRm9yV29yayhXb3JrZXIgY29uc3QgJncpCiAgewogIAl3LndvcmsoKTsKICB9Cn07CgppbnQgbWFpbigpIHsKICBFbXBsb3llciBlOwogIAogIHR5cGVkZWYgc3RydWN0IDogV29ya2VyIHsKICAJdm9pZCB3b3JrKCkgY29uc3Qgb3ZlcnJpZGUKICAJewogIAkgIHN0ZDo6Y291dCA8PCAiSSdtIHdvcmtpbmdcbiI7CiAgCX0KICB9IExvY2FsV29ya2VyVDsKICAKICBzdHJ1Y3QgOiBXb3JrZXIgewogIAl2b2lkIHdvcmsoKSBjb25zdCBvdmVycmlkZQogIAl7CiAgCSAgc3RkOjpjb3V0IDw8ICJJJ20gd29ya2luZyB0b29cbiI7CiAgCX0KICB9IExvY2FsV29ya2VyOwogIAogIGUuYXNrRm9yV29yayhMb2NhbFdvcmtlclQge30pOwogIGUuYXNrRm9yV29yayhMb2NhbFdvcmtlcik7Cn0=