You initialize an array of pointers just as you would any other array, you assign values to positions. That wouldn't cause memory leaks.
What causes memory leaks is the creation of objects (either explicitly or implied) and then not cleaning up after yourself. Every "new" needs a "delete". Every "malloc" needs a "free".
Watch for implied creations like trying to use classes like primitive data types. The most notorious there is the string class. Like any other object, any string created needs to be deleted.
Hope that helps you find your leak!
Ratchetr
2010-11-06 00:46:48 UTC
It really, really, really depends on what you are trying to do here.
Can you at least post a snippet of code, with how you are trying to initialize your array?
One basic rule: For every new, you must have a delete, or you will have memory leaks. They shouldn't kill your computer, though.
oops
2010-11-06 01:03:59 UTC
Note, this code assumes you are using a modern compiler, like GCC 4.5 or VS2010.