Computer Science Canada

declaring arrays

Author:  Blade [ Thu Apr 03, 2003 7:03 pm ]
Post subject:  declaring arrays

i was wondering if you could redeclare arrays... such as you declare an array with 3 elements, then you want to make it bigger, could you redeclare it with 5 elements... and if you cant, how can you do it?

Author:  Catalyst [ Thu Apr 03, 2003 7:34 pm ]
Post subject: 

you would have to declare it as a flexible array

code:


var names:flexible array 1..1 of string



to change the upper parameter...

code:


new names,5 %% 5 is the new max


Author:  Blade [ Thu Apr 03, 2003 7:35 pm ]
Post subject: 

ah ic... this is gonna be so sweet, thanks a lot catalyst

Author:  Tony [ Thu Apr 03, 2003 8:36 pm ]
Post subject: 

yea.. or you can just declear it to be big to begin with Wink

C++ doesnt allow dynamic arrays (array range must be known at compile time). Thats why they usually give you rangest on contests such as CCC ("test data will have up to 100 numbers" - so dim array as 100).

but thats C++... though turing is compiled in C++, so I dont think your flexible array will increase program performance... I'd like someone to correct/backup on that though


: