Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generic array

Status
Not open for further replies.

AncientyHacker

Programmer
Aug 19, 2010
1
US
So I'm playing with this newfangled generic feature.

Kinda cool, you can paremeterize the type of the array elements:

MultiArray<Ty> = record
Items: array[ 1..100 ] of Ty;
end;

Next thing, I'd like to paremeterize the index type:


MultiArray<Ty,Inx> = record
Items: array[ Inx ] of Ty;
end;

... but no joy, the compiler complains about that. It wants an already defined ordinal type. Sigh.

Why would there be such a severe restriction like that?
 
Dude - Both '<' and '>' are reserved characters for 'less than' and 'greater than', respectively. Something any 'Ancient Hacker' should know. LOL

Roo
Delphi Rules!
 
No roo,

he has a valid point.
This is the syntax for Generics.

AncientyHacker, Generics are more suited for OOP.
arrays are really not suited for this. You can solve your problem with TList<T> though.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Sorry AND thanks. I'll have to read up on 'Generics'.
:~/

Roo
Delphi Rules!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top