X
Xiaoshen Li
Dear All,
I am a little confused.
//Objects of this class are partially filled arrays of doubles
class PFArray
{
public:
...
~PFArray();
private:
double *a; //for an array of doubles
..
};
PFArray::~PFArray()
{
delete [] a;
}
The code "double *a" in the private section of class PFArray doesn't
NECESSARILY tell that a is a pointer to an array (it coulde be a pointer
to a double, right?). Why the deconstructor use " delete [] a "? If a
instead is pointer to a double, then "delete a" should be used?
I am a little confused.
//Objects of this class are partially filled arrays of doubles
class PFArray
{
public:
...
~PFArray();
private:
double *a; //for an array of doubles
..
};
PFArray::~PFArray()
{
delete [] a;
}
The code "double *a" in the private section of class PFArray doesn't
NECESSARILY tell that a is a pointer to an array (it coulde be a pointer
to a double, right?). Why the deconstructor use " delete [] a "? If a
instead is pointer to a double, then "delete a" should be used?