comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: unconstrained subtype in component declaration, tagged OO
Date: Sat, 26 Mar 2011 21:42:16 +0100
Date: 2011-03-26T21:42:14+01:00	[thread overview]
Message-ID: <1v6bdfssnx5jd$.1k5a6782kgvu5.dlg@40tude.net> (raw)
In-Reply-To: imli2b$mbe$1@speranza.aioe.org

On Sat, 26 Mar 2011 13:24:37 -0700, Nasser M. Abbasi wrote:

> I am learning a bit about Ada OO, and I have simple problem,
> hopefully with simple answer, but not able to find one so far.
> 
> I want to make an object, but the declaration of the tagged record
> would include an array in it. The size of this array, at the
> time of declaration is not know. But will be when the
> object is created.
> 
> So, what is the correct way to declare such an object?
> 
> Here is my ads package for the object:
> 
> -------------------foo.ads-------
> package foo is
>     type foo_t is tagged private;

   type foo_t (<>) is tagged private;

>     -- primitive operations
>     function make(n:natural) return foo_t;
> private
>      type u_t is array(natural range<>) of float;
> 
>      type foo_t is tagged record
>           u : u_t:= (others=>0.0);  -- problem here
>      end record;

   type foo_t (Length : Natural) is tagged record
      u : u_t (1..Length) := (others=>0.0);
   end record;


   function make(n:natural) return foo_t is
   begin
      return (n, (others => 0.0));
   end make;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2011-03-26 20:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-26 20:24 unconstrained subtype in component declaration, tagged OO Nasser M. Abbasi
2011-03-26 20:42 ` Dmitry A. Kazakov [this message]
2011-03-26 22:50   ` Nasser M. Abbasi
2011-03-27  3:23     ` John B. Matthews
2011-03-27  9:42     ` Dmitry A. Kazakov
2011-03-27 20:58       ` Nasser M. Abbasi
replies disabled

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