If I'm right in saying this, you haven't used the new keyword. So there's nothing to delete.
If you create and 'object' of this struct within a function, then the memory will be freed when it goes out of scope. i.e. the function it was created in ends.
so the new is used. and i want the function erasecont to delete everything that was created by this function (i hope i am explaining myself well, i just want to free memory).
int *testFunc()
{
int *me = newint;
*me = 5;
return me;
}
void eraseMe( int *value )
{
delete value;
}
int main()
{
int *meCopy = testFunc();
eraseMe( meCopy );
return 0;
}
Hopefully someone with more knowledge will see this thread, lol.
I'd also like to know if this is actually deleting the memory taken by 'new' in the above function.
delete[] is usually used for deleating arrays. For single objects only use delete.
You create your item as cont rcont = new contrib
if you would create it using cont rcont = new contrib[x]; then you would use delete[];