exception Découvert
class compte_géré ?seuil:(s=10000.) ?init:(i=0.) c  =
  object (self)
    inherit Compte.client i as banque
    val épargne = c
    method investir x = épargne # dépôt (self # retrait x)
    method dépôt x =
      banque # dépôt x; if self#solde > s then
      self#investir (float (truncate s / 2))
    method retrait x =     (* pour ne pas avoir de pénalité *)
      if self#solde < x then raise Découvert else banque#retrait x
  end;;  
    
let caisse_épargne = new Compte.client 2000.0;;
let ccp = new compte_géré ~init:1000. caisse_épargne;;