<!-- Link to source file download -->
Download source files - 2 Kb
<!-- Add the rest of your HTML here -->
is a simple array class template. It is especially useful when you need to dynamically allocate arrays of objects in functions that have many possible return points. Instead of having to call
delete  pArray
at each return point, you can let the ISArray destructor handle it for you.
ISArray < char > charArray(256);
charArray.Fill( (char)0 );
char *pArray = (char *)charArray;
If you had allocated the array the traditional C++ way, with
char *pArray = new char;
or the traditional C way, using
pArray = (char *)malloc(256);
you would have had to call
delete  pArray; or
free(pArray) at each return point. But, with
ISArray destructor handles this for you. This insures against memory leaks, and makes your code much cleaner to look at. In extreme cases (such as the one we wrote it for) this class can actually cut down the size of your app, by eliminating all of the clean-up code.
ISArray allows you to delay the allocation of the memory, instead of doing it in the
ISArray constructor. This can be very handy if the allocation is conditional. Of course, you don't have to test that the array has been allocated before deleting it, the
ISArray destructor handles this for you, too.
We've also included some handy utility functions to copy one array to another, set/get the array size, etc..
#include <span class="code-string">"ISArray.h"</span>
ISArray <CString> stringArray(100);
ISArray <BYTE> bytes1;
ISArray <BYTE> bytes2;
bytes2 = bytes1;
Remember - have fun.