Mercurial > projects > ldc
comparison test/interface4.d @ 113:27b9f749d9fe trunk
[svn r117] Initial working implementation of interfaces.
Groundwork for all the different types of class/interface casts laid out.
author | lindquist |
---|---|
date | Sat, 24 Nov 2007 06:33:00 +0100 |
parents | |
children | 44a95ac7368a |
comparison
equal
deleted
inserted
replaced
112:368547b1cbe6 | 113:27b9f749d9fe |
---|---|
1 module interface4; | |
2 | |
3 interface I | |
4 { | |
5 void func(); | |
6 } | |
7 | |
8 interface I2 | |
9 { | |
10 void func(); | |
11 } | |
12 | |
13 class C : I,I2 | |
14 { | |
15 int i = 42; | |
16 override void func() | |
17 { | |
18 printf("hello %d\n", i); | |
19 i++; | |
20 } | |
21 } | |
22 | |
23 void main() | |
24 { | |
25 scope c = new C; | |
26 c.func(); | |
27 I i = c; | |
28 i.func(); | |
29 I2 i2 = c; | |
30 i2.func(); | |
31 printf("final %d\n", c.i); | |
32 assert(c.i == 45); | |
33 } |