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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5e2f26fe9df6f729,start X-Google-Attributes: gid103376,public From: jsa@alexandria.organon.com (Jon S Anthony) Subject: Re: Class object initialization.... Date: 1997/10/09 Message-ID: #1/1 X-Deja-AN: 279050017 References: <343BEFFE.200574F6@linkabit.titan.com> Distribution: world Organization: PSINet Newsgroups: comp.lang.ada Date: 1997-10-09T00:00:00+00:00 List-Id: In article <343BEFFE.200574F6@linkabit.titan.com> Marc Bejerano writes: > type foo is tagged record > a: integer := -1234; > end record; > > type bar is new foo with record > b: natural := 1234; > end record; > > How would I "initialize" data member 'a' inside of bar? In C++ I would > do this in the constructor. How would I do this in Ada95? (Can I do this > in Ada95?) What do you mean by "inside of bar"?? Wherever the structures are visible an aggregate takes the place of a C++ constructor: X : Bar := (A => 13, B => 31); or simply X : Bar := (13, 31); or, in a derived case such as this X : Bar := (foo with B => 77); If the structures are not visible, you could use controlled types, which have user definable initialization procedures per type. You might also try discriminants. /Jon -- Jon Anthony STL, Belmont, MA 02178, 617.484.3383 "Nightmares - Ha! The way my life's been going lately, Who'd notice?" -- Londo Mollari