mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-05 14:33:14 +01:00
[svn r117] Initial working implementation of interfaces.
Groundwork for all the different types of class/interface casts laid out.
This commit is contained in:
28
test/interface3.d
Normal file
28
test/interface3.d
Normal file
@@ -0,0 +1,28 @@
|
||||
module interface3;
|
||||
|
||||
interface I
|
||||
{
|
||||
void func();
|
||||
}
|
||||
|
||||
class C : I
|
||||
{
|
||||
int i = 42;
|
||||
override void func()
|
||||
{
|
||||
printf("hello %d\n", i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
scope c = new C;
|
||||
{c.func();}
|
||||
{
|
||||
I i = c;
|
||||
{i.func();}
|
||||
}
|
||||
{printf("final %d\n", c.i);}
|
||||
{assert(c.i == 44);}
|
||||
}
|
||||
Reference in New Issue
Block a user