Best Tutorials website


Using vector instead of arrays to prevent most of memory leaks

Using vector instead of arrays to prevent most of memory leaks

Most of beginners define arrays of limited size such as:

int array[100]; // array that can accomodate 100 integer values

These are ok, but your requirement may be different, and you want your application to determines the size of array at runtime, so if your requirement is to use 10 elements only, that means 90 are unused but memory is still allocated for them while application is running. On other hand your application requires 110 elements to be saved, the last 10 will be unallocated spaces if array size is 100, and access to unallocated memory address may result in applciation crash and/or system level damage.




Views: 575 | Rating star | by David




View this tutorial
Broken link Report broken link?