Mercurial > projects > ldc
comparison tests/mini/t.d @ 341:1bb99290e03a trunk
[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author | lindquist |
---|---|
date | Sun, 13 Jul 2008 02:51:19 +0200 |
parents | tangotests/t.d@336ec4f4bbb3 |
children |
comparison
equal
deleted
inserted
replaced
340:351c0077d0b3 | 341:1bb99290e03a |
---|---|
1 interface MyInterface | |
2 { | |
3 int func(); | |
4 } | |
5 | |
6 class MyClass : MyInterface | |
7 { | |
8 int var; | |
9 int func() | |
10 { | |
11 return var; | |
12 } | |
13 } | |
14 | |
15 void func1(MyInterface i) | |
16 { | |
17 int delegate() dg = &i.func; | |
18 func2(dg); | |
19 } | |
20 | |
21 extern(C) int printf(char*, ...); | |
22 | |
23 void func2(int delegate() dg) | |
24 { | |
25 int i = dg(); | |
26 printf("%d\n", i); | |
27 } | |
28 | |
29 void main() | |
30 { | |
31 auto c = new MyClass; | |
32 c.var = 42; | |
33 func1(c); | |
34 } |