From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,71c743c03ed191fe X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-15 08:45:59 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!crtntx1-snh1.gtei.net!chcgil2-snf1.gtei.net!news.gtei.net!news.binc.net!kilgallen From: Kilgallen@SpamCop.net (Larry Kilgallen) Newsgroups: comp.lang.ada Subject: Re: Beginer problem: variable array size Date: 15 Sep 2002 10:45:56 -0600 Organization: LJK Software Message-ID: References: NNTP-Posting-Host: eisner.encompasserve.org X-Trace: grandcanyon.binc.net 1032103386 31691 192.135.80.34 (15 Sep 2002 15:23:06 GMT) X-Complaints-To: abuse@binc.net NNTP-Posting-Date: Sun, 15 Sep 2002 15:23:06 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:28983 Date: 2002-09-15T10:45:56-06:00 List-Id: In article , "Nacho" 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.