Hi,
I was wondering if I can do the following without creating memory problems:
Create something like -- int * array1 -- as a public member my class
then initiate it with a new value every time I run a certain function, like this --- array1 = new int[somenumber] ---
but ONLY delete it in the destructor --- delete [] array1 ---
If I reinitiate it with a new value before deleting it, what happens to the old memory which it occupies? Also, can I call ---- array1 = NULL --- or does that not work for arrays?
Thanks a lot,
Crispin
I was wondering if I can do the following without creating memory problems:
Create something like -- int * array1 -- as a public member my class
then initiate it with a new value every time I run a certain function, like this --- array1 = new int[somenumber] ---
but ONLY delete it in the destructor --- delete [] array1 ---
If I reinitiate it with a new value before deleting it, what happens to the old memory which it occupies? Also, can I call ---- array1 = NULL --- or does that not work for arrays?
Thanks a lot,
Crispin
Comment