Resizable Data Structures

The use of memory blocks and arrays (which are basically typed memory blocks) for data storage has several great advantages, such as quick and direct access and ease of implementation. Implementing arrays is a task which is fairly straightforward and far less error-prone and time-consuming than, say, using linked lists. The reason arrays are often put aside as valid programming solutions, though, is that their size seems to be too static in nature. Often array size is specified at compile time or it is determined at array-creation time, after which it does not change until the array is destroyed. Arrays are often declared as follows:

 void MakeArrays(int size) { char name[200]; // size determined at compile time. char ...

Get C++ Footprint and Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.