I am very new to C++ and came across this section of code in an
example, whilst learning about dynamic memory. The example uses the
delete operator in a for loop, it seems to imply that each time the
loop runs the memory for the array will be deleted. I don't think this
is correct. Can someone offer me an explanation as to why this code
works?
I have only included the section which includes the for loop and the
delete operator.
cout << "You have entered: ";
for (n=0; n<i; n++)
cout << p[n] << ", ";
delete[] p;
}
return 0;
}
Thank you very much