comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: constructor in abstract tagged types
Date: Fri, 10 May 2019 17:40:46 -0500
Date: 2019-05-10T17:40:46-05:00	[thread overview]
Message-ID: <qb4ule$3gs$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 0ca05176-a819-4e9a-8c6c-3a0c1f32f964@googlegroups.com

"Daniel" <danielnorberto@gmail.com> wrote in message 
news:0ca05176-a819-4e9a-8c6c-3a0c1f32f964@googlegroups.com...
...
>Option 2:
>
>  return Son'(Father with
 >              Skate =>True);
>
>Problem: i cannot initialize Father or call any kind of constructor of 
>Father
>becouse compiler don't let me make any kind of function of a abstract 
>tagged type.

Correct. But that's what you declared in this case, so I would assume that 
you want to manually initialize all of the components.

If you have proper default values for the components, why not declare the 
Father type that way?? Uninitialized stuff often leads to trouble anyway.

That is:

  type Father is abstract tagged record
     Years : Natural := 0;
     field1 : Natural := 0;
--    .....and 15 more fields
  end record;

If you *don't* want this sort of default value, then it only makes sense to 
initialize all of the components when the object is first created. (Or you 
could define a procedure to do it, as Dmitry showed. But you lose 
completeness checking when you do that.)

                                    Randy.







  parent reply	other threads:[~2019-05-10 22:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 18:37 constructor in abstract tagged types Daniel
2019-05-08 19:26 ` Dmitry A. Kazakov
2019-05-18 11:31   ` Daniel
2019-05-08 20:50 ` Jere
2019-05-10 22:35   ` Randy Brukardt
2019-05-09 14:40 ` AdaMagica
2019-05-10  4:46   ` Petter Fryklund
2019-05-18 11:35   ` Daniel
2019-05-10 22:40 ` Randy Brukardt [this message]
2019-05-18 11:43   ` Daniel
replies disabled

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