Mercurial > projects > ldc
comparison tangotests/t.d @ 143:336ec4f4bbb3 trunk
[svn r147] tango.io.Console is now working. True this time :) Yay!
author | lindquist |
---|---|
date | Fri, 25 Jan 2008 01:42:36 +0100 |
parents | aeddd4d533b3 |
children |
comparison
equal
deleted
inserted
replaced
142:a123dca8349b | 143:336ec4f4bbb3 |
---|---|
1 interface MyInterface | 1 interface MyInterface |
2 { | 2 { |
3 void func(); | 3 int func(); |
4 } | 4 } |
5 | 5 |
6 abstract class MyBaseClass : MyInterface | 6 class MyClass : MyInterface |
7 { | 7 { |
8 abstract void func(); | 8 int var; |
9 int func() | |
10 { | |
11 return var; | |
12 } | |
9 } | 13 } |
10 | 14 |
11 class MyClass : MyBaseClass | 15 void func1(MyInterface i) |
12 { | 16 { |
13 void func() | 17 int delegate() dg = &i.func; |
14 { | 18 func2(dg); |
15 } | 19 } |
16 | 20 |
17 MyBaseClass toBase() | 21 extern(C) int printf(char*, ...); |
18 { | 22 |
19 return this; | 23 void func2(int delegate() dg) |
20 } | 24 { |
25 int i = dg(); | |
26 printf("%d\n", i); | |
21 } | 27 } |
22 | 28 |
23 void main() | 29 void main() |
24 { | 30 { |
25 printf("STARTING\n"); | |
26 auto c = new MyClass; | 31 auto c = new MyClass; |
27 printf("c = %p\n", c); | 32 c.var = 42; |
28 auto b = c.toBase; | 33 func1(c); |
29 printf("b = %p\n", b); | |
30 printf("FINISHED\n"); | |
31 } | 34 } |
32 | |
33 extern(C) int printf(char*, ...); |