I'm trying to get a grip on the OCaml language syntax and am having some trouble with applying some OOP structures. My goal with the below code is to have a class bar that inherits from a virtual class foo. The virtual class contains three virtual methods that I hope to take an instance of a "player" object as a parameter. When I compile the below code, I get the error: The method doThis has type 'a -> 'b but is expected to have type player . What does this mean (remember, I'm new at this) and how do I go about correcting it?
Thanks!
class player =
object
end;;
class virtual foo =
object (self)
method virtual doThis : player
method virtual doThat : player
method virtual notifyAll : player array
end;;
class bar (playersIn: player array) =
object (self)
inherit foo
method doThis (p:player) = Printf.printf "%s\n" "This!"
method doThat (p:player) = Printf.printf "%s\n" "That!"
method notifyAll (p:player array) = Printf.printf "%s\n" "Notifying!"
end;;