From: "mr1yh1" <mr1yh1@yahoo.com>
Subject: a beginner question
Date: Wed, 20 Oct 2004 19:01:47 -0400
Date: 2004-10-20T19:01:47-04:00 [thread overview]
Message-ID: <10b97a973c8cc17010b8a5e9d55be273@localhost.talkaboutprogramming.com> (raw)
i am very new in ada , i try to write codes from book and see result
i tried something but i couldnt get a good result
(i use gnat)
******************
with Ada.Text_Io;use Ada.Text_Io;
procedure test is
type Sex_T is
(Male,
Female);
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
Me : Person;
she : Person (Female); ---- and this one ,
begin
Me:=(
S => Male,
Sex => Male,
Age => 33,
Has_Wife => True);
she:=(
S => Female,
Sex => Male, ---please look at here now!!!!!
Age => 23,
Has_Husband => True);
Put(Sex_T'Image(she.Sex));
end test;
****
there is not any alert
and result is
" male " ??
if i dont put "sex=>male" , or "sex=>female"
it dont let me to use a named association...
even is i dont put " s=> female "
it dont let me too ,
but i said about discriminant
when i declare the variable ( she : person(female) )
why its not possible ?
to put
she:=(age=>23,has_husband=>true);
regards
next reply other threads:[~2004-10-20 23:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-20 23:01 mr1yh1 [this message]
2004-10-20 23:53 ` a beginner question Björn Persson
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