mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-12 02:43:14 +01:00
35 lines
364 B
D
35 lines
364 B
D
module interface5;
|
|
|
|
extern(C) int printf(char*,...);
|
|
|
|
interface I
|
|
{
|
|
void func();
|
|
}
|
|
|
|
class C : I
|
|
{
|
|
int i;
|
|
void func()
|
|
{
|
|
printf("C\n");
|
|
i++;
|
|
}
|
|
}
|
|
|
|
void main()
|
|
{
|
|
C c = new C;
|
|
c.func();
|
|
{
|
|
I i = c;
|
|
i.func();
|
|
|
|
C c2 = cast(C)i;
|
|
c2.func();
|
|
|
|
c.func();
|
|
assert(c.i == 4);
|
|
}
|
|
}
|