#include <iostream>
#include<vector>
using namespace std;
typedef struct{
int x = 0;
int y = 0;
}Point;
class A{
public:
A(Point* s) {
p = s;
}
~A()
{
if (p) {
delete p;
p = NULL;
}
}
private:
Point* p;
};
int main()
{
Point* point = new Point();
A* a = new A(point);
if (point) {
delete point;
point = NULL;
}
if (a) {
delete a;
a = NULL;
}
}
point已被化为零,却没把类A的实例化里同一地址的p清零,怎么办??万分感谢!