[求助]为什么会是这样的结果?
#include <cstdlib>
#include <iostream>
using namespace std;
class point
{
public:
int x;
int y;
point(int x,int y);
~point();
void print();
};
point::point(int x,int y)
{
this->x=x;
this->y=y;
}
point::~point()
{
cout<<"Unload me"<<endl;
}
void point::print()
{
cout<<"x= "<<this->x<<endl;
cout<<"Y= "<<this->y<<endl;
}
int main(int argc, char *argv[])
{
point* xy=new point(10,10);
xy->print();
delete xy;
xy->print();
system("PAUSE");
return EXIT_SUCCESS;
}
/*
运行结果:
x= 10
y= 10
Unload me
x=0
y=10
为什么结果会是这样的呢,我预期的结果是:
x= 10
y= 10
Unload me
x=0
y=0
谢谢!
*/