From: "Nacho" <NACHANGA@terra.es>
Subject: Re: Beginer problem: variable array size
Date: Sun, 15 Sep 2002 18:16:51 +0200
Date: 2002-09-15T18:16:51+02:00 [thread overview]
Message-ID: <am2bq5$8fl$1@nsnmpen2-gest.nuria.telefonica-data.net> (raw)
In-Reply-To: HFiRcRlG5JiR@eisner.encompasserve.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2277 bytes --]
That does not resolve the problem. I need to change the size of the array
after it has been created. With your solution once array_called_p has been
created it will never change its size.
I need this:
... preceding Ada statements
declare -- scope of array_called_p
type my_array_type is array ( positive range <> ) of integer;
array_called_p : my_array_type ( 1 .. variable );
begin -- scope of array_called_p
... Ada statements that use array_called_p
variable := variable+50; -- We increase the size of the array in 50
elementes
.... HERE I need array_called_p to increase its size so it can hold
50 more elements
end; -- scope of array_called_p
... following Ada statements
The solution in c++ is easy as I posted before. Simply free the memory and
reserve new memory to hold the new size of the array.
"Larry Kilgallen" <Kilgallen@SpamCop.net> escribi� en el mensaje
news:HFiRcRlG5JiR@eisner.encompasserve.org...
> In article <am26u4$d2q$1@nsnmpen2-gest.nuria.telefonica-data.net>, "Nacho"
<NACHANGA@terra.es> writes:
> > Hi everyone!
> >
> > I am learning ada and i have to implement an array of unknown size until
> > rutime.
> > The array must be resizable at runtime. This is easy to achieve for me
in
> > other lenguajes like c++, but i am new to ada and i don't know hot to
> > resolve the problem. The solution in c++ code could be:
> >
> >
> >
> > int variable=50; //let's make an array of 50 elements.
> > int* p; //pointer to int, if the array is of integers.
> > p=new int[variable]; //we reserve memory for 50 integers.
> >
> >
> > .... //some code with the array here.
> >
> > delete [] p; //we free the allocated memory for the array.
> > variable=80; //we change the size of the array.
> > p=new int[variable]; //we have a new array with the new size.
>
> Wow, C looks like a lot of work !!!!!
>
> ... preceding Ada statements
>
> declare -- scope of array_called_p
> type my_array_type is array ( positive range <> ) of integer;
> array_called_p : my_array_type ( 1 .. variable );
> begin -- scope of array_called_p
> ... Ada statements that use array_called_p
> end; -- scope of array_called_p
>
> ... following Ada statements
>
> In general, Ada rarely requires pointers.
next prev parent reply other threads:[~2002-09-15 16:16 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-15 14:53 Beginer problem: variable array size Nacho
2002-09-15 16:45 ` Larry Kilgallen
2002-09-15 16:16 ` Nacho [this message]
2002-09-15 16:26 ` Ludovic Brenta
2002-09-15 17:46 ` Jeffrey Carter
2002-09-15 18:27 ` Pascal Obry
2002-09-15 20:03 ` Larry Kilgallen
2002-09-17 14:22 ` Ted Dennison
2002-09-18 11:53 ` Marin David Condic
2002-10-02 15:08 ` Matthew Heaney
2002-10-03 12:17 ` Marin David Condic
2002-09-19 0:43 ` Robert A Duff
2002-09-19 1:25 ` Jeffrey Carter
2002-09-19 14:17 ` Hyman Rosen
2002-09-20 3:06 ` Munch
2002-09-20 4:49 ` Jim Rogers
2002-09-20 6:35 ` tmoran
2002-09-20 16:00 ` Pat Rogers
2002-09-20 16:07 ` Preben Randhol
2002-09-20 20:15 ` Pat Rogers
2002-09-20 12:11 ` Marin David Condic
2002-09-20 13:59 ` Larry Kilgallen
2002-09-20 14:55 ` Hyman Rosen
2002-09-20 16:10 ` Larry Kilgallen
2002-09-20 16:31 ` Warren W. Gay VE3WWG
2002-09-24 12:41 ` Thomas Dickey
2002-09-21 10:44 ` Thomas Dickey
2002-09-23 13:37 ` Hyman Rosen
2002-09-22 13:00 ` Marin David Condic
2002-09-26 3:37 ` Kevin Cline
2002-09-26 12:42 ` Marin David Condic
2002-09-22 12:49 ` Marin David Condic
2002-09-20 16:28 ` Warren W. Gay VE3WWG
2002-09-20 17:49 ` Hyman Rosen
2002-09-21 7:30 ` Preben Randhol
2002-09-23 13:41 ` Hyman Rosen
2002-09-22 3:34 ` Ted Dennison
2002-09-22 13:18 ` Marin David Condic
2002-09-24 16:55 ` Warren W. Gay VE3WWG
2002-09-25 12:06 ` Marin David Condic
2002-09-21 22:23 ` tmoran
2002-09-23 13:53 ` Hyman Rosen
2002-09-23 15:19 ` Chad R. Meiners
2002-09-23 16:00 ` Hyman Rosen
2002-09-23 17:09 ` tmoran
2002-09-23 18:18 ` Hyman Rosen
2002-09-23 19:53 ` tmoran
2002-09-23 20:32 ` Hyman Rosen
2002-09-23 20:10 ` Dennis Lee Bieber
2002-09-23 23:09 ` tmoran
2002-09-24 2:33 ` Dennis Lee Bieber
2002-09-24 12:36 ` Marin David Condic
2002-10-02 15:13 ` Matthew Heaney
2002-09-19 20:25 ` Brian Gaffney
2002-09-17 10:20 ` Georg Bauhaus
2002-10-02 15:04 ` Matthew Heaney
2002-10-02 16:26 ` Preben Randhol
2002-10-02 19:53 ` Matthew Heaney
2002-10-03 12:31 ` Marin David Condic
2002-10-03 15:15 ` Matthew Heaney
2002-10-21 23:38 ` Matthew Heaney
2002-10-22 14:11 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox