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 specific ['a] queuesubtype collectionand ['a] iterator_queuesubtype classes iterator.
I mainly want to know how to define a method iterator : unit -> 'a iterator, because I do not see how these two types can be related. Do I need to ['a] iterator_queueinherit from both abstract ones? or I have to act differently.
source
share