<dl class="problem-params" style="color:rgb(35,31,23);font-family:'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif;font-size:14px;"> <dt> 总时间限制: </dt> <dd style="margin-left:0px;"> 1000ms </dd> <dt> 内存限制: </dt> <dd style="margin-left:0px;"> 65536kB </dd> </dl> <dl class="problem-content" style="color:rgb(35,31,23);font-family:'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif;font-size:14px;"> <dt style="font-size:16px;line-height:56px;"> 描述 </dt> <dd style="margin-left:0px;">
1样例输入
程序填空,输出指定结果
#include <iostream>
using namespace std;
class A {
public:
int i;
A(int x) { i = x; }
</dd> </dl> // 在此处补充你的代码
};
int main()
{
A a(1);
A * pa = new A(2);
delete pa;
return 0;
}
输入无输出2 1样例输入
无2样例输出
2
完整代码:(所用知识: 析构函数
#include <iostream>
using namespace std;
class A
{
public:
int i;
A(int x)
{
i = x;
}
~A()
{
cout<<i<<endl;
}
};
int main()
{
A a(1);
A * pa = new A(2);
delete pa;
return 0;
}