#include <iostream>
class B {
protected:
const int a_;
int b_;
B (int b, int a) : a_(a), b_(b) {}
public:
operator bool () const { return b_ == a_; }
};
class D1 : public B {
public:
D1 (int b = 0, int a = 0) : B(b, a) {}
operator int () const { return b_; }
};
class D2 : public B {
public:
D2 (int b = 0, int a = 0) : B(b, a) {}
operator const int & () const { return b_; }
};
int main () {
if (D1 d1a = D1('a', 'a')) std::cout << "d1a\n";
if (D1 d1b = D1('b', 'a')) std::cout << "d1b\n";
if (D2 d2a = D2('a', 'a')) std::cout << "d2a\n";
if (D2 d2b = D2('b', 'a')) std::cout << "d2b\n";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgQiB7CnByb3RlY3RlZDoKICAgIGNvbnN0IGludCBhXzsKICAgIGludCBiXzsKICAgIEIgKGludCBiLCBpbnQgYSkgOiBhXyhhKSwgYl8oYikge30KcHVibGljOgogICAgb3BlcmF0b3IgYm9vbCAoKSBjb25zdCB7IHJldHVybiBiXyA9PSBhXzsgfQp9OwogCmNsYXNzIEQxIDogcHVibGljIEIgewpwdWJsaWM6CiAgICBEMSAoaW50IGIgPSAwLCBpbnQgYSA9IDApIDogQihiLCBhKSB7fQogICAgb3BlcmF0b3IgaW50ICgpIGNvbnN0IHsgcmV0dXJuIGJfOyB9Cn07CiAKY2xhc3MgRDIgOiBwdWJsaWMgQiB7CnB1YmxpYzoKICAgIEQyIChpbnQgYiA9IDAsIGludCBhID0gMCkgOiBCKGIsIGEpIHt9CiAgICBvcGVyYXRvciBjb25zdCBpbnQgJiAoKSBjb25zdCB7IHJldHVybiBiXzsgfQp9OwogCmludCBtYWluICgpIHsKICAgIGlmIChEMSBkMWEgPSBEMSgnYScsICdhJykpIHN0ZDo6Y291dCA8PCAiZDFhXG4iOwogICAgaWYgKEQxIGQxYiA9IEQxKCdiJywgJ2EnKSkgc3RkOjpjb3V0IDw8ICJkMWJcbiI7CiAgICBpZiAoRDIgZDJhID0gRDIoJ2EnLCAnYScpKSBzdGQ6OmNvdXQgPDwgImQyYVxuIjsKICAgIGlmIChEMiBkMmIgPSBEMignYicsICdhJykpIHN0ZDo6Y291dCA8PCAiZDJiXG4iOwogICAgcmV0dXJuIDA7Cn0=