From: "Björn Persson" <spam-away@nowhere.nil>
Subject: Re: a beginner question
Date: Wed, 20 Oct 2004 23:53:19 GMT
Date: 2004-10-20T23:53:19+00:00 [thread overview]
Message-ID: <PTCdd.6701$d5.56118@newsb.telia.net> (raw)
In-Reply-To: <10b97a973c8cc17010b8a5e9d55be273@localhost.talkaboutprogramming.com>
mr1yh1 wrote:
> type Person ( S:Sex_T:=Male )is
> record
> Age:Positive ;
> Sex:Sex_T:=S;------please look at here first
> case S is
> when Male =>
> Has_Wife:Boolean ;
> when Female=>
> Has_Husband:Boolean;
> end case;
> end record;--person end
You have defined a person with two independent sexes. By default, Sex is
initialized to the same value as S, but it's perfectly possible to
change it.
Just remove Sex and let S be the person's sex.
> Put(Sex_T'Image(she.Sex));
This line then becomes:
Put(Sex_T'Image(she.S));
> why its not possible ?
> to put
> she:=(age=>23,has_husband=>true);
The parenthesis here is called an aggregate. An aggregate must provide
values for all the components. But you can do:
She.Age := 23;
She.Has_Husband := True;
--
Björn Persson PGP key A88682FD
omb jor ers @sv ge.
r o.b n.p son eri nu
next prev parent reply other threads:[~2004-10-20 23:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-20 23:01 a beginner question mr1yh1
2004-10-20 23:53 ` Björn Persson [this message]
2004-10-21 11:47 ` Marius Amado Alves
2004-10-21 18:16 ` mr1yh1
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox