#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();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCnN0cnVjdCBJQmFzZQp7CiAgICB2aXJ0dWFsIGJvb2wgZm9vKCljb25zdD0wOwp9OwoKc3RydWN0IElEZXI6IElCYXNlCnsKICAgIHZpcnR1YWwgYm9vbCBiYXoxKCljb25zdD0wOwogICAgdmlydHVhbCBib29sIGJhejIoKWNvbnN0PTA7Cn07CgpzdHJ1Y3QgU3RhbmRhcnQ6IElCYXNlCnsKICAgIHZpcnR1YWwgYm9vbCBmb28oKWNvbnN0IHsgY291dDw8IlN0YW5kYXJ0OmZvb1xuIjsgcmV0dXJuIGZhbHNlOyB9Cn07CnN0cnVjdCBEZXI6IFN0YW5kYXJ0CnsKICAgIHZpcnR1YWwgYm9vbCBiYXoyKCljb25zdCB7IGNvdXQ8PCJEZXI6YmF6MlxuIjsgcmV0dXJuIGZhbHNlOyB9CiAgICB2aXJ0dWFsIGJvb2wgYmF6MSgpY29uc3QgeyBjb3V0PDwiRGVyOmJhejFcbiI7IHJldHVybiBmYWxzZTsgfQp9OwoKaW50IG1haW4oKQp7CiAgICBzdGQ6OmNvdXQgPDwgIkhlbGxvLCB3b3JsZCFcbiI7CiAgIAogICAgRGVyIGQ7CiAgICAKICAgIC8v0L3QtSDRgNCw0LHQvtGC0LDQtdGCINC/0L7RgtC+0LzRgyDR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