I have these two classes in OCaml
class type ['a] collection =
object
method add : 'a -> unit
method clear : unit -> unit
method iterator : unit -> 'a iterator
method remove : 'a -> unit
end
class type ['a] iterator =
object
method hasNext : unit -> bool
method next : unit -> 'a
end
And I need to create two concrete classes ['a] queue
subtype of collection
and ['a] iterator_queue
a subtype of iterator
.
I want mainly to know how to define the method iterator : unit -> 'a iterator
because I don't see how the two types can be connected, Does the ['a] iterator_queue
has to be inherited from both the abstract ones? or should I proceed differently.
Thank you.