Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] object
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: inv2002 <inv2002@y...>
Subject: [Caml-list] object
class virtual obj = object
    ...
  end

class a_obj = object
  inherit obj
  method a_fun = ...
end

class b_obj = object
  inherit obj
  method b_fun = ...
end

class object_list = object
  val ht = Hashtbl.create 5

  method add: 'a. string -> (#obj as 'a) -> unit = fun key o ->
    Hashtbl.add ht key (o :> obj) (* i don't know right way, how to store objects *)

  method find key =
    Hashtbl.find ht key

end

i want to store a_obj and b_obj in object_list,
after find it and execute a_fun method
if the object is a_obj

--
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners