comp.lang.ada
 help / color / mirror / Atom feed
* a beginner question
@ 2004-10-20 23:01 mr1yh1
  2004-10-20 23:53 ` Björn Persson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mr1yh1 @ 2004-10-20 23:01 UTC (permalink / 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




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

end of thread, other threads:[~2004-10-21 18:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-20 23:01 a beginner question mr1yh1
2004-10-20 23:53 ` Björn Persson
2004-10-21 11:47 ` Marius Amado Alves
2004-10-21 18:16 ` mr1yh1

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