-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// define a public Foo class (picked up by @import) | ||
public class Foo | ||
{ | ||
// member variable | ||
int num; | ||
|
||
// constructor | ||
fun Foo( int n ) { n => num; } | ||
} | ||
|
||
// a non-public class definition (ignored by @import) | ||
class Bar | ||
{ | ||
// ... | ||
} | ||
|
||
// public operator overloading + for Foo (picked up by @import) | ||
public Foo @operator +( Foo lhs, Foo rhs ) | ||
{ | ||
// return a new Foo | ||
return new Foo ( lhs.num + rhs.num ); | ||
} | ||
|
||
// non-public binary operator overload for '=>' (ignored by @import) | ||
fun void @operator =^( Foo lhs, Foo rhs ) | ||
{ | ||
// for sake of example, just print contents | ||
<<< lhs.num, "=^", rhs.num >>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// import | ||
@import "Foo.ck" | ||
|
||
// instantiate class defined in imported file | ||
Foo a(1), b(2); | ||
|
||
// use operator overload defined in imported file | ||
<<< (a + b).num >>>; |