46 lines
981 B
Plaintext
46 lines
981 B
Plaintext
import util:*
|
|
import io:*
|
|
|
|
obj test(Object) {
|
|
var counter:int
|
|
fun construct(): test* {
|
|
counter = 0
|
|
println("construct with 0")
|
|
return this
|
|
}
|
|
|
|
fun construct(it:int): test* {
|
|
counter = it
|
|
print("construct with "); println(it)
|
|
return this
|
|
}
|
|
|
|
fun copy_construct(old: test*):void {
|
|
counter = old->counter+1
|
|
print("copy construct from "); print(old->counter); print(" to "); println(counter)
|
|
}
|
|
|
|
fun destruct():void {
|
|
print("destruct with "); println(counter)
|
|
}
|
|
}
|
|
|
|
fun main():int {
|
|
println(lesser(1,2))
|
|
println(lesser(7.0,8.0))
|
|
println(greater(1,2))
|
|
println(greater(7.0,8.0))
|
|
|
|
var oddPair = make_pair(3, "hi")
|
|
println(oddPair.first)
|
|
println(oddPair.second)
|
|
|
|
println("construct")
|
|
var test1.construct():test
|
|
var test2.construct(100):test
|
|
println("make_pair")
|
|
var test_pair = make_pair(test1, test2)
|
|
println("done")
|
|
return 0
|
|
}
|