Created
April 26, 2015 13:48
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
[<AbstractClass>] | |
type AbstractPoint | |
= class | |
val mutable vx: int; | |
val mutable vy: int; | |
new(x,y) = { vx = x; vy = y } | |
member p.x with get() = p.vx and set z = p.vx <- z | |
member p.y with get() = p.vy and set z = p.vy <- z | |
abstract move: AbstractPoint -> unit | |
end | |
type Point' | |
= class | |
inherit AbstractPoint | |
new(x,y) = { inherit AbstractPoint(x,y) } | |
override p.move q = p.x <- p.x + q.x; | |
p.y <- p.y + q.y | |
end | |
let p = Point'(2,3) | |
let q = Point'(1,2) | |
p.move(q) | |
p.x | |
p.y;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment