急! 求各位大佬帮我看下,一道很简单的C++程序运行结果题目,以及改错,我明天考试了,谢谢哥哥姐姐们了
五、(1)写出程序执行显示结果(8分)(2)程序中存在隐含的严重问题,指出并修改。(7分)#include<iostream.h>classCbase{public:Cb...
五、(1)写出程序执行显示结果(8分)
(2)程序中存在隐含的严重问题,指出并修改。(7分)
#include<iostream.h>
class Cbase
{ public:
Cbase(){};
~ Cbase(){ cout << " ~ Cbase () is called.\n" ; }
} ;
class CFirst : public Cbase
{ public:
CFirst(){};
~ CFirst (){ cout << "~ CFirst () is called.\n" ; }
} ;
void main()
{
Cbase *Ap = new CFirst;
CFirst *Bp = new CFirst ;
cout << "delete A object:\n" ;
delete Ap;
cout << "delete B object:\n" ;
delete Bp ;
} 展开
(2)程序中存在隐含的严重问题,指出并修改。(7分)
#include<iostream.h>
class Cbase
{ public:
Cbase(){};
~ Cbase(){ cout << " ~ Cbase () is called.\n" ; }
} ;
class CFirst : public Cbase
{ public:
CFirst(){};
~ CFirst (){ cout << "~ CFirst () is called.\n" ; }
} ;
void main()
{
Cbase *Ap = new CFirst;
CFirst *Bp = new CFirst ;
cout << "delete A object:\n" ;
delete Ap;
cout << "delete B object:\n" ;
delete Bp ;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |