N
Nethali
Hi all,
Please explain me the following:
I have struct as follows:
struct Link
{
void* data;
Link* next;
}
And I do following:
Link* newLink = new Link;
newLink->data = new string("aaaaaaaaaaaa");
newLink->next = 0;
My problem is this:
Above, I have allocated 2 memory areas, one for newLink and one for
string of "aaaaaaaaaaaa".
If I delete newLink ( ie: delete newLink; ) it will release the memory
area for newLink. Will it release the memory area allocated for
"aaaaaaaaaaaa" also? If so how it happens? If it is not so, how can I
relase memory area allocated for "aaaaaaaaaaaa"?
Thanks in advance.
Please explain me the following:
I have struct as follows:
struct Link
{
void* data;
Link* next;
}
And I do following:
Link* newLink = new Link;
newLink->data = new string("aaaaaaaaaaaa");
newLink->next = 0;
My problem is this:
Above, I have allocated 2 memory areas, one for newLink and one for
string of "aaaaaaaaaaaa".
If I delete newLink ( ie: delete newLink; ) it will release the memory
area for newLink. Will it release the memory area allocated for
"aaaaaaaaaaaa" also? If so how it happens? If it is not so, how can I
relase memory area allocated for "aaaaaaaaaaaa"?
Thanks in advance.