Mercurial > projects > ldc
comparison test/staticarrays.d @ 1:c53b6e3fe49a trunk
[svn r5] Initial commit. Most things are very rough.
author | lindquist |
---|---|
date | Sat, 01 Sep 2007 21:43:27 +0200 |
parents | |
children | d9d5d59873d8 |
comparison
equal
deleted
inserted
replaced
0:a9e71648e74d | 1:c53b6e3fe49a |
---|---|
1 void numbers() | |
2 { | |
3 bool[8] bools; | |
4 char[8] chars; | |
5 byte[8] bytes; | |
6 short[8] shorts; | |
7 int[8] ints; | |
8 long[8] longs; | |
9 float[8] floats; | |
10 double[8] doubles; | |
11 real[8] reals; | |
12 { | |
13 bools[7] = true; | |
14 floats[7] = 3.14159265; | |
15 { | |
16 printf("bools[0] = %d, bools[7] = %d\n", bools[0], bools[7]); | |
17 printf("floats[0] = %f, floats[7] = %f\n", floats[0], floats[7]); | |
18 } | |
19 } | |
20 } | |
21 | |
22 struct S | |
23 { | |
24 int i = 42; | |
25 void print() | |
26 { | |
27 printf("S.i = %d\n", i); | |
28 } | |
29 } | |
30 | |
31 class C | |
32 { | |
33 int i; | |
34 this() | |
35 { | |
36 i = 3; | |
37 } | |
38 void print() | |
39 { | |
40 printf("C.i = %d\n", i); | |
41 } | |
42 } | |
43 | |
44 void refs() | |
45 { | |
46 void*[5] voids; | |
47 S*[5] structs; | |
48 C[5] classes; | |
49 | |
50 { | |
51 voids[0] = cast(void*)0xA; | |
52 printf("void* = %p\n", voids[0]); | |
53 } | |
54 { | |
55 structs[0] = new S; | |
56 structs[0].print(); | |
57 delete structs[0]; | |
58 } | |
59 { | |
60 classes[0] = new C; | |
61 classes[0].print(); | |
62 delete classes[0]; | |
63 } | |
64 } | |
65 | |
66 void main() | |
67 { | |
68 numbers(); | |
69 refs(); | |
70 } |