Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Problem with classes or i need help
[ 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] Problem with classes or i need help
I don't know correct solution of my problem.

Here my example:
---begin 1.ml---
#!/usr/bin/env ocamltop

class virtual figure () =
  object
    method virtual to_string: string
  end

class triangle () =
  object
    inherit figure ()
    method private to_string = "Triangle"
    method m1 = Random.float 5.0
  end

class circle () =
  object
    inherit figure ()
    method private to_string = "Circle"
    method m2 = Random.int 6
  end

class screen () =
  object
    val mutable figures = []
    method add_figure f =
      figures <- (f#to_string ) :: figures
  end

let main () =
  let s1 = new screen () in 
  s1#add_figure (new circle ());
  s1#add_figure (new triangle ())

let () = main ()

--end---
[inv@localhost ~]$ ./1.ml
File "./1.ml", line 22, characters 5-121:
Some type variables are unbound in this type:
  class screen :
    unit ->
    object
      val mutable figures : 'a list
      method add_figure : < to_string : 'a; .. > -> unit
    end
The method add_figure has type < to_string : 'a; .. > -> unit where ..
is unbound

I understand the problem, but i don't know solution, help, please.
--
-------------------
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