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-17 03:20:26 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: Beginer problem: variable array size Date: Tue, 17 Sep 2002 10:20:25 +0000 (UTC) Organization: GMUGHDU Message-ID: References: NNTP-Posting-Host: l1-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1032258025 17560 134.91.1.34 (17 Sep 2002 10:20:25 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Tue, 17 Sep 2002 10:20:25 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/800)) Xref: archiver1.google.com comp.lang.ada:29064 Date: 2002-09-17T10:20:25+00:00 List-Id: Nacho wrote: : 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. : 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. Hm. You said you wanted to resize p. If I'm not mistaken then you are creating two unrelated arrays of different sizes (new), and in each case you let p point to the newly created array. That is, the int values of the firsts instance of p need not be present in the second instance of p? I think this isn't what "resizing an array" usually means. However, the Ada solution Larry has given shows the way to the same solution in Ada. You just create two different array values and name them where you need them. If you are working with two completely different arrays anyway, that happen to be pointed to by the same pointer variable, then why not consider separating the solutions into related parts? (As you don't seem to work with values from "the 1st p" in "the 2nd p".) -- Georg