Mercurial > lcfOS
comparison examples/c3/types.c3 @ 300:158068af716c
yafm
author | Windel Bouwman |
---|---|
date | Tue, 03 Dec 2013 18:00:22 +0100 |
parents | test/c3examples/types.c3@d9df72971cbf |
children |
comparison
equal
deleted
inserted
replaced
299:674789d9ff37 | 300:158068af716c |
---|---|
1 | |
2 /* | |
3 Demo of how to define types | |
4 */ | |
5 | |
6 module typedemo; | |
7 | |
8 type int A; | |
9 type int B; | |
10 type struct { | |
11 int x, y; | |
12 A z; | |
13 } C; | |
14 type struct { | |
15 C x; | |
16 B y; | |
17 int z; | |
18 } D; | |
19 | |
20 type D* E; | |
21 | |
22 function int testcast() | |
23 { | |
24 var A a; | |
25 var B b; | |
26 a = 3; | |
27 b = a; | |
28 var C c; | |
29 c.x = a; | |
30 c.z = c.y; | |
31 var D d; | |
32 var E e; | |
33 var D* e2; | |
34 e = &d; | |
35 e2 = e; | |
36 e2->x.x = 22; | |
37 | |
38 return 0; | |
39 } | |
40 |