#include <iostream>
struct Base
{
public:
Base(int a) : _a(a) { }
protected:
int _a;
bool operator == ( const Base& other ) const
{
return (_a == other._a);
}
};
struct Derived : public Base
{
Derived(int a) : Base(a) { }
bool operator == ( const Derived& other ) const
{
return Base::operator==(other);
//return static_cast<Base>(*this) == static_cast<Base>(other);
}
};
int main()
{
Derived b1(0), b2(0), b3(5);
std::cout << std::boolalpha << (b1 == b2) << std::endl;
std::cout << (b1 == b3) << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IEJhc2UKewoJcHVibGljOgoJCUJhc2UoaW50IGEpIDogX2EoYSkgeyB9CiAgICBwcm90ZWN0ZWQ6CiAgICBpbnQgX2E7CiAgICBib29sIG9wZXJhdG9yID09ICggY29uc3QgQmFzZSYgb3RoZXIgKSBjb25zdAogICAgewogICAgICAgIHJldHVybiAoX2EgPT0gb3RoZXIuX2EpOwogICAgfQp9OwoKc3RydWN0IERlcml2ZWQgOiBwdWJsaWMgQmFzZQp7CglEZXJpdmVkKGludCBhKSA6IEJhc2UoYSkgeyB9CiAgICBib29sIG9wZXJhdG9yID09ICggY29uc3QgRGVyaXZlZCYgb3RoZXIgKSBjb25zdAogICAgewogICAgCXJldHVybiBCYXNlOjpvcGVyYXRvcj09KG90aGVyKTsKICAgICAgICAvL3JldHVybiBzdGF0aWNfY2FzdDxCYXNlPigqdGhpcykgPT0gc3RhdGljX2Nhc3Q8QmFzZT4ob3RoZXIpOwogICAgfQp9OwoKaW50IG1haW4oKQp7CiAgICBEZXJpdmVkIGIxKDApLCBiMigwKSwgYjMoNSk7CiAgICBzdGQ6OmNvdXQgPDwgc3RkOjpib29sYWxwaGEgPDwgKGIxID09IGIyKSA8PCBzdGQ6OmVuZGw7CiAgICBzdGQ6OmNvdXQgPDwgKGIxID09IGIzKSA8PCBzdGQ6OmVuZGw7Cn0=