However, I would strongly recommend you don't use the code I posted. you ca make this code far simpler and safer if you use constructors and destructors. At the very least make the CTuple destructor delete the m_P array. But you might also want to make the constructor allocate the array as well.

>>Am I deleteing all the memory I had allocated? I think I am missing something?
I don't see anything that is missed. But by using constructors/destructors you can make this much easier to manage so you won't have any doubts. Also, if you are using VC, you can use its debug heap features to detect if any memory is alocated without being freed.

how can I use the debug heap in VC 5.0?
There are different ways, depending on what you want to accomplist. If you look up "debug heap" in the online help you will find lots of info. For starters, I would use _CrtSetDbgfFlg() to set the _CRTDBG_LEAK_CHECK_DF flag. With this flag set, when the program quits, VC will print a list of all memory blkcjs that here allocated but not destroyed. See the CrtSetDbfFls() function in the docs.

Another good thing to do is to overide the 4 allocation/deallocate operators (new, new [], delete, and delete[]) to have overides that take a file name and line number as parameters. These overloaded functions should call _malloc_debug() and _free_dbg() instead of the ussual malloc() and free() that most new and delete overides call. This allows them to specify the file name and line number when the memory is allocated. This way, when a memory error is detected, VC will be able to report the line number where the memory was allocated. This is great help. To make this work well use the preprocessor to define macros ("#define") for new and delete. These macros then call the overloaded new and delete operators and pass the file name and line number using __FILE__ and __LINE__.

This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++.
The reason I built this class is to ease the pain of using XML files with C++, since there is…

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects.
A brief on problem:
Lets take example problem for simplicity:
- I have a G…