该法典是否造成记忆泄露:
int main(){
int * a = new int[10];
int * b = new int[10];
for(int i = 0 ; i < 10; i++)
{
a[i] = 1;
b[i] = 1;
}
for(int i = 0 ; i < 10; i++)
{
a[i] = b[i]; //each a[i] is allocated 4 bytes on heap
//when we copy b[i] into a[i] do we loose
//the reference to a[i] (hence a leak),
//and replace that reference
//with a reference to a new value?
}
delete[] a;
delete[] b;
}