From: Marius Amado Alves <amado.alves@netcabo.pt>
To: comp.lang.ada@ada-france.org
Subject: Re: oo problem help please
Date: Mon, 08 Dec 2003 23:19:37 +0000
Date: 2003-12-08T23:19:37+00:00 [thread overview]
Message-ID: <mailman.49.1070925576.31149.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <4948f537.0312081149.70179416@posting.google.com>
On Mon, 2003-12-08 at 19:49, shoko wrote:
> what is wrong with the following code:
> ...
> type car is tagged
> record
> name:String(1..256);
> end record;
> ...
> procedure set_name(name:String;This:in out car)is
> begin
> this.name:=name;
My guess is this last line.
> ... the problem is that i get constraint error when the code is executed
> why???
Ditto.
Possible fixes:
- pad (or trim) to 256 before assigning;
- make sure the target is initialized to spaces (say), and that the
source is no longer than the target, and then write This.Name (1 ..
Target'Length) := Name;
- redefine the component to be a pointer to string, then write This.Name
:= new String' (Name);
next prev parent reply other threads:[~2003-12-08 23:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-08 19:49 oo problem help please shoko
2003-12-08 23:19 ` Marius Amado Alves [this message]
2003-12-09 16:45 ` Martin Krischik
2003-12-09 16:42 ` Martin Krischik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox