G
Ge Chunyuan
Eg. we have the class hiaerarchy Point inherit Point3D
class Point
{
public:
Point(int a=0,char* b=0):x(a),y(b){}
private:
int x;
char* y;
};
class Point3D: public Point
{
public:
Point3D(char*c=0):z(c){}
private:
char* z;
}
Once we instatiate an array like this:
Point* pPointArray = new Point3D[10];
delete[] pPointArray;
why this will cause memory leak?
will delete recursively invoke Point3D's destructor.
Thanks indeed
Ge Chunyuan
class Point
{
public:
Point(int a=0,char* b=0):x(a),y(b){}
private:
int x;
char* y;
};
class Point3D: public Point
{
public:
Point3D(char*c=0):z(c){}
private:
char* z;
}
Once we instatiate an array like this:
Point* pPointArray = new Point3D[10];
delete[] pPointArray;
why this will cause memory leak?
will delete recursively invoke Point3D's destructor.
Thanks indeed
Ge Chunyuan