| 1 |
// define a public Foo class (picked up by @import) |
| 2 |
public class Foo |
| 3 |
{ |
| 4 |
// member variable |
| 5 |
int num; |
| 6 |
|
| 7 |
// constructor |
| 8 |
fun Foo( int n ) { n => num; } |
| 9 |
} |
| 10 |
|
| 11 |
// a non-public class definition (ignored by @import) |
| 12 |
class Bar |
| 13 |
{ |
| 14 |
// ... |
| 15 |
} |
| 16 |
|
| 17 |
// public operator overloading + for Foo (picked up by @import) |
| 18 |
public Foo @operator +( Foo lhs, Foo rhs ) |
| 19 |
{ |
| 20 |
// return a new Foo |
| 21 |
return new Foo ( lhs.num + rhs.num ); |
| 22 |
} |
| 23 |
|
| 24 |
// non-public binary operator overload for '=>' (ignored by @import) |
| 25 |
fun void @operator =^( Foo lhs, Foo rhs ) |
| 26 |
{ |
| 27 |
// for sake of example, just print contents |
| 28 |
<<< lhs.num, "=^", rhs.num >>>; |
| 29 |
} |