comp.lang.ada
 help / color / mirror / Atom feed
* constructor in abstract tagged types
@ 2019-05-08 18:37 Daniel
  2019-05-08 19:26 ` Dmitry A. Kazakov
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Daniel @ 2019-05-08 18:37 UTC (permalink / raw)



Hello, im trying to know how can i use abstract tagged types and constructors at the same time.

I have this

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

  function F_build(Years :Natural) return Father is abstract;
  procedure F_forced_to_do_it is abstract;
end FATHERS;

package FATHERS.SONS is
type Son is new father with record
   skate : boolean;
end Son;

function F_Build(Years :Natural) return Son;
procedure F_Forced_to_do_it;
end FATHERS.SONS;

package body FATHERS.SONS is

function F_Build(Years : Natural) return Son is
begin

  ¿?¿?¿?¿?¿?

end F_Build;

end FATHERS.SONS;


---------------------------------
So the question is How can i make the constructor F_Build of the Son?

Option 1:

  return son'(Years => Years,
              field1 => ¿?,
              field2 => ¿?.
              ...
              field15 => ?¿

Problem: put 15 fields by hand for every type of son.. really annoying.

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.

Regards,
Daniel.






^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-18 11:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-05-18 11:43   ` Daniel

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