comp.lang.ada
 help / color / mirror / Atom feed
From: agate!spool.mu.edu!olivea!charnel!rat!koko.csustan.edu!nic.csu.net!vmsa.i s.csupomona.edu!marasigan@ucbvax.Berkeley.EDU  (GABRIEL MARASIGAN PA)
Subject: question on constant arrays
Date: 4 Feb 93 04:48:00 GMT	[thread overview]
Message-ID: <3FEB199320484448@vmsa.is.csupomona.edu> (raw)

    Is it possible to declare an array of record types, with a string
within the record say like in 'C': 
    struct mytype {
    	char *Name;
    	int T;
    };
    struct mytype foo[] = {{"Hi", 1}, {"There!", 2}};

    I have tried:
    	type MY_TYPE(Size : positive := 1) is
    	    record
    		Name : STRING(1..Size);
    		T    : INTEGER;
    	    end record;

    	type MY_ARRAY is array(positive range <>) of MY_TYPE;
    	Foo : constant MY_ARRAY := ((size => 2, Name => "Hi", T => 1)....) ?

    and the compiler balked at me. It seems that you can do:
    	NAME : constant STRING := "Hi";    	
    and since type STRING is declared to be: 
    	type STRING is array (positive range <>) of CHARACTER;
    the compiler shouldn't have any problems figuring out how
    many MY_TYPE records I am actually putting in my constant
    array. If it could figure it out for strings, why not for 
    MY_TYPE? Or is the problem with MY_TYPE's 'Size' need to 
    be bound before hand? Or is it because the compiler 
    'knows' that my project is due in 2 days?

    	Thanks in advance for any info.


    					Gabriel
    					marasigan@csupomona.edu

             reply	other threads:[~1993-02-04  4:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-02-04  4:48 agate!spool.mu.edu!olivea!charnel!rat!koko.csustan.edu!nic.csu.net!vmsa.i [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-02-05  1:58 question on constant arrays David Emery
1993-02-05 14:10 Mike Lijewski
replies disabled

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