Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Break-OO-privacy/OCaml/break-oo-privacy.ocaml
Normal file
33
Task/Break-OO-privacy/OCaml/break-oo-privacy.ocaml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
class point x y =
|
||||
object
|
||||
val mutable x = x
|
||||
val mutable y = y
|
||||
method print = Printf.printf "(%d, %d)\n" x y
|
||||
method dance =
|
||||
x <- x + Random.int 3 - 1;
|
||||
y <- y + Random.int 3 - 1
|
||||
end
|
||||
|
||||
type evil_point {
|
||||
blah : int;
|
||||
blah2 : int;
|
||||
mutable x : int;
|
||||
mutable y : int;
|
||||
}
|
||||
|
||||
let evil_reset p =
|
||||
let ep = Obj.magic p in
|
||||
ep.x <- 0;
|
||||
ep.y <- 0
|
||||
|
||||
let () =
|
||||
let p = new point 0 0 in
|
||||
p#print;
|
||||
p#dance;
|
||||
p#print;
|
||||
p#dance;
|
||||
p#print;
|
||||
let (_, _, x, y) : int * int * int * int = Obj.magic p in
|
||||
Printf.printf "Broken coord: (%d, %d)\n" x y;
|
||||
evil_reset p
|
||||
p#print
|
||||
Loading…
Add table
Add a link
Reference in a new issue