examples/func/func_obj_arg.ck
raw| 1 | // class with function taking class as argument |
| 2 | |
| 3 | class Other |
| 4 | { |
| 5 | 10 => int x; |
| 6 | int y; |
| 7 | } |
| 8 | |
| 9 | class X |
| 10 | { |
| 11 | int x; |
| 12 | int y; |
| 13 | |
| 14 | public void set( Other a ) |
| 15 | { |
| 16 | a.x => x; |
| 17 | a.y => y; |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | // instantiate |
| 22 | Other a; |
| 23 | X x; |
| 24 | |
| 25 | // call the function |
| 26 | x.set(a); |
| 27 | |
| 28 | // test |
| 29 | if( a.x == 10 ) <<<"success">>>; |