#include <iostream>
using namespace std;
struct ILogger {
virtual ~ILogger() {}
virtual void log(string m) = 0;
};
class Car {
ILogger* logger;
public:
explicit Car(ILogger* l)
: logger(l) {
}
void drive() {
logger->log("driving is so good");
}
};
class Trailer : public Car, private ILogger {
public:
Trailer() : Car(this) {
}
void unpack() {
log("unpacking trailer");
}
void log(string m) override {
// putting record in our journal
cout << "[trailer journal]: " << m << endl;
}
};
int main() {
Trailer t;
t.unpack();
// it's time to move
t.drive();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IElMb2dnZXIgewogICAgdmlydHVhbCB+SUxvZ2dlcigpIHt9CiAgICB2aXJ0dWFsIHZvaWQgbG9nKHN0cmluZyBtKSA9IDA7Cn07CgpjbGFzcyBDYXIgewogICAgSUxvZ2dlciogbG9nZ2VyOwoKcHVibGljOgogICAgZXhwbGljaXQgQ2FyKElMb2dnZXIqIGwpCiAgICAgICAgOiBsb2dnZXIobCkgewoKICAgIH0KCiAgICB2b2lkIGRyaXZlKCkgewogICAgICAgIGxvZ2dlci0+bG9nKCJkcml2aW5nIGlzIHNvIGdvb2QiKTsKICAgIH0KfTsKCmNsYXNzIFRyYWlsZXIgOiBwdWJsaWMgQ2FyLCBwcml2YXRlIElMb2dnZXIgewpwdWJsaWM6CiAgICBUcmFpbGVyKCkgOiBDYXIodGhpcykgewoKICAgIH0KCiAgICB2b2lkIHVucGFjaygpIHsKICAgICAgICBsb2coInVucGFja2luZyB0cmFpbGVyIik7CiAgICB9CgogICAgdm9pZCBsb2coc3RyaW5nIG0pIG92ZXJyaWRlIHsKICAgICAgICAvLyBwdXR0aW5nIHJlY29yZCBpbiBvdXIgam91cm5hbAogICAgICAgIGNvdXQgPDwgIlt0cmFpbGVyIGpvdXJuYWxdOiAiIDw8IG0gPDwgZW5kbDsKICAgIH0KfTsKCmludCBtYWluKCkgewogICAgVHJhaWxlciB0OwogICAgdC51bnBhY2soKTsKICAgIC8vIGl0J3MgdGltZSB0byBtb3ZlCiAgICB0LmRyaXZlKCk7CgogICAgcmV0dXJuIDA7Cn0=