December 12, 2003

Use Lazy Initialization to Conserve Resources

Say you have an object with a property that uses a relatively large amount of resources?and you know the property may never be accessed. Consider waiting to create the property until it’s actually needed?especially if you are creating large numbers of these objects. Delaying creation in this manner is called

Remove an Element in a Sorted Array

To remove an element at a given position in a sorted array, shift all the elements above it down one position. void erase(int a[], int& n, int index) { // function: // Removes key at a[index], shifting other values down as necessary. // Updates number of elements in a. //