a beginner question
From: mr1yh1 (mr1yh1_at_yahoo.com)
Date: 10/21/04
- Next message: Björn Persson: "Re: Is T an ancestor of T?"
- Previous message: Georg Bauhaus: "Re: Is T an ancestor of T?"
- Next in thread: Björn Persson: "Re: a beginner question"
- Reply: Björn Persson: "Re: a beginner question"
- Reply: Marius Amado Alves: "Re: a beginner question"
- Reply: mr1yh1: "Re: a beginner question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 20 Oct 2004 19:01:47 -0400
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 message: Björn Persson: "Re: Is T an ancestor of T?"
- Previous message: Georg Bauhaus: "Re: Is T an ancestor of T?"
- Next in thread: Björn Persson: "Re: a beginner question"
- Reply: Björn Persson: "Re: a beginner question"
- Reply: Marius Amado Alves: "Re: a beginner question"
- Reply: mr1yh1: "Re: a beginner question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|