Hi, all
i am reading some memory leaking problem articles now.
Here is one question i can't understand:
char *a= new char[10];
char *b= new char[10];
b=a;//pointer assignment
delete []b;
In this article, it mentioned that the pointer assignment have side-effect and we couldn't delete pointer b from heap anymore.
its better use strcpy(b,a) function.
My question is:
is that correct??
if we couldn't delete b from heap what's the
delete []b;
used for??
And why the last line of the code free the dynamic variable associated with pointer a??
Thanks.