comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: array and pointers
Date: Sat, 22 Nov 2003 15:16:46 GMT
Date: 2003-11-22T15:16:46+00:00	[thread overview]
Message-ID: <t5Lvb.278102$Fm2.287644@attbi_s04> (raw)
In-Reply-To: 4948f537.0311220139.570c8a4e@posting.google.com

To create a new dynamically allocated array and initialize it with the
result from Array_Filter use:

  N := new Arr'( Array_Filter( A ) );

Also, since you say you're new to Ada, I'll also mention that this is an
unusual way of doing things in Ada.  A more common approach is to use
something like:

  declare
    Filtered_Data : Arr := Array_Filter( A );
  begin
    -- Do stuff with Filtered_Data here
  end;

Which avoids dynamic allocation on the heap altogether.

Steve
(The Duck)

"shoko" <shoko2004@hotmail.com> wrote in message
news:4948f537.0311220139.570c8a4e@posting.google.com...
> hi
> i am new in ada
> my question is:
> i have a function that returns unconstrained array
> i am tring to create a pointer to the new array
> could somone help me:
>
> what is wwrong in the following code?:
>
> type Arr is Array(Item range<>) of Integer;
> a:Arr:=(1,2,2,2,3,4,3) ;
> type n_array_Ptr is access Arr;
> n: n_array_Ptr;
>
> begin
>      n:= new Array_filter(a);
>
>      put_line("hello");





  parent reply	other threads:[~2003-11-22 15:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-22  9:39 array and pointers shoko
2003-11-22 10:16 ` Gautier Write-only
2003-11-22 15:16 ` Steve [this message]
2003-11-22 17:45 ` Jeffrey Carter
2003-11-23  2:09   ` Hyman Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox