请写出下面程序的运行结果。
#include
using namespace std;
class A
{
public:
int a = 1;
A()
{
a = 2;
cout << a << endl;
}
A(int a)
{
this->a = a;
cout << a << endl;
}
A(float a)
{
this->a = a;
cout << a << endl;
}
~A()
{
cout << a << endl;
}
};
void main(void)
{
A *p1 = new A();
A *p2 = new A(10);
A *p3 = new A(1.0f);
delete p1;
delete p2;
delete p3;
}
查看答案和解析【26考研辅导课程推荐】:26考研集训课程,VIP领学计划,26考研VIP全科定制套餐(公共课VIP+专业课1对1) , 这些课程中都会配有内部讲义以及辅导书和资料,同时会有教研教辅双师模式对大家进行教学以及督学,并配有24小时答疑和模拟测试等,可直接咨询在线客服老师领取大额优惠券。
启航教育热门私房课
MORE小班面授 名额有限 抢先体验
编辑推荐
最新内容