Re: Class hierarchy of exceptions (Ada, C++)

From: Pascal Obry (pascal_at_obry.net)
Date: 03/30/05


Date: 30 Mar 2005 14:01:45 +0200


Tapio Kelloniemi <spam17@thack.org> writes:

> >> procedure X is
> >>
> >> type Metres is new Natural;
> >> type Seconds is new Natural;
> >>
> >> M : Metrses := 0;
> >> S : Seconds := 10;
> >> begin
> >> if M < S then -- Error, < is not defined for these types
> >
> >But now you have problems calculating the velocity, right?
> >
> >type Velocity is new Natural;
> >V: Velocity = M/S; // probably a compiler error.
>
> Yes, but I can tell the compiler that I know better:
> V : Velocity := Velocity (Integer (M) / Integer (S));

or

   function "/" (M : in Metres; S : in Seconds) return Velocity;

Pascal.

-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595