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("aaaaaaa aaaaa");
newLink->next = 0;
My problem is this:
Above, I have allocated 2 memory areas, one for newLink and one for
string of "aaaaaaaaaa aa".
If I delete newLink ( ie: delete newLink; ) it will release the memory
area for newLink. Will it release the memory area allocated for
"aaaaaaaaaa aa" also? If so how it happens? If it is not so, how can I
relase memory area allocated for "aaaaaaaaaa aa"?
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("aaaaaaa aaaaa");
newLink->next = 0;
My problem is this:
Above, I have allocated 2 memory areas, one for newLink and one for
string of "aaaaaaaaaa aa".
If I delete newLink ( ie: delete newLink; ) it will release the memory
area for newLink. Will it release the memory area allocated for
"aaaaaaaaaa aa" also? If so how it happens? If it is not so, how can I
relase memory area allocated for "aaaaaaaaaa aa"?
Thanks in advance.
Comment