OB
Size: a a a
Тᅠ
МВ
МВ
МВ
Тᅠ
OB
import std;
interface Foo { void foo(); }
class FooImpl : Foo { override void foo() { writeln("foo_impl"); } }
class Bar : FooImpl { override void foo() { writeln("bar"); } }
void call1(Foo f)
{
f.foo();
writeln(cast(void*)cast(FooImpl)f);
if (auto i = cast(FooImpl)f)
i.foo();
writeln();
}
void call2(FooImpl f)
{
f.foo();
writeln(cast(void*)cast(Bar)f);
if (auto i = cast(Bar)f)
i.foo();
writeln();
}
void main()
{
auto o = new Bar;
call1(o); // ok
call2(o); // ok
//call1(cast(Foo)cast(void*)o); // ne ok
call2(cast(FooImpl)cast(void*)o); // ok
}
МВ
Тᅠ
МВ
МВ
МВ
EP
КП
Тᅠ
Тᅠ
EP
Тᅠ
Тᅠ
КП