View Single Post
Old 02-21-2006, 11:28 AM   #5 (permalink)
kyoryu
Registered User
 
Join Date: Apr 2003
Posts: 34
kyoryu is on a distinguished road
Quote:
Originally Posted by DJMaze
Nice but it doesn't always work.
I got my compiler fail a few times if the array is defined outside main.
Instead i had to use vector or alloc()
Code:
int array = new int[10];
// but can't resize it now
array = new int[100]; // error
Use an int*, not an int. In C, arrays are basically pointers with prettier semantics.

Code:
int *array = new int[ 10 ];
array = new int[ 100 ];
It'll compile and run, but it is an automatic memory leak.
kyoryu is offline   Reply With Quote