#include <iostream>
using namespace std;
struct IBase
{
virtual bool foo()const=0;
};
struct IDer: IBase
{
virtual bool baz1()const=0;
virtual bool baz2()const=0;
};
struct Standart: IBase
{
virtual bool foo()const { cout<<"Standart:foo\n"; return false; }
};
struct Der: Standart
{
virtual bool baz2()const { cout<<"Der:baz2\n"; return false; }
//virtual bool baz1()const { cout<<"Der:baz1\n"; return false; }
};
int main()
{
std::cout << "Hello, world!\n";
Der d;
//не работает потому что IDer не является частью иерархии Der
//IDer& id = static_cast<IDer&>(d);
IDer& id = reinterpret_cast<IDer&>(d);
id.baz1();
id.baz2();
id.foo();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCnN0cnVjdCBJQmFzZQp7CiAgICB2aXJ0dWFsIGJvb2wgZm9vKCljb25zdD0wOwp9OwoKc3RydWN0IElEZXI6IElCYXNlCnsKICAgIHZpcnR1YWwgYm9vbCBiYXoxKCljb25zdD0wOwogICAgdmlydHVhbCBib29sIGJhejIoKWNvbnN0PTA7Cn07CgpzdHJ1Y3QgU3RhbmRhcnQ6IElCYXNlCnsKICAgIHZpcnR1YWwgYm9vbCBmb28oKWNvbnN0IHsgY291dDw8IlN0YW5kYXJ0OmZvb1xuIjsgcmV0dXJuIGZhbHNlOyB9Cn07CnN0cnVjdCBEZXI6IFN0YW5kYXJ0CnsKICAgIHZpcnR1YWwgYm9vbCBiYXoyKCljb25zdCB7IGNvdXQ8PCJEZXI6YmF6MlxuIjsgcmV0dXJuIGZhbHNlOyB9CiAgICAvL3ZpcnR1YWwgYm9vbCBiYXoxKCljb25zdCB7IGNvdXQ8PCJEZXI6YmF6MVxuIjsgcmV0dXJuIGZhbHNlOyB9Cn07CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6Y291dCA8PCAiSGVsbG8sIHdvcmxkIVxuIjsKICAgCiAgICBEZXIgZDsKICAgIAogICAgLy/QvdC1INGA0LDQsdC+0YLQsNC10YIg0L/QvtGC0L7QvNGD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