I am reading a textbook and it seems to indicate that when you have a member variable that's a pointer, you have to put code in the destructor in order to delete the memory.
It's a little unclear but it seems that the code has to look like this:
private:
double *aPtr;
public:
~NumberArray(){ delete [ ] aPtr;}
Doesn't this end up being 2 delete commands, though, because the destructor is already deleting the first element in that array? Also, do destructors automatically do their default work, even if you have 1 or more lines in your program for the default destructor? Does the program execute your code first or it executes the code the "automatic" part of the destructor?
For some reason I thought that the delete command is just used for dynamically allocated memory. I guess I am wrong about that?