C++.阅读程序,写出运行结果,求大神学霸
#include<iostream.h>classA{private:intX,Y;public:A(){X=Y=0;cout<<"DefaultConstructorc...
#include
<iostream.h>
class
A
{ private:
int X,Y;
public:
A( ) { X=Y=0;
cout<<"Default
Constructor called."<<endl;
}
A(int xx,int yy) {
X=xx;Y=yy;
cout<< "Constructor
called."<<endl;
}
~A( ) { cout<<"Destructor called."<<endl; }
};
void
main()
{
A
*p1=new A;
delete p1;
p1=new
A(1,2);
delete
p1;
} 展开
<iostream.h>
class
A
{ private:
int X,Y;
public:
A( ) { X=Y=0;
cout<<"Default
Constructor called."<<endl;
}
A(int xx,int yy) {
X=xx;Y=yy;
cout<< "Constructor
called."<<endl;
}
~A( ) { cout<<"Destructor called."<<endl; }
};
void
main()
{
A
*p1=new A;
delete p1;
p1=new
A(1,2);
delete
p1;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询