根据下列程序的执行结果,可以断定划线部分的修饰符应为______。执行结果: i9a football is created. a football is created. i=10 a football is destroyed.

admin2010-12-16  31

问题 根据下列程序的执行结果,可以断定划线部分的修饰符应为______。执行结果:
   i9a football is created.
   a football is created.
   i=10
   a football is destroyed.
   a football is created.
   i=20
   a football is destroyed.
   a football is destroyed.
   源程序:
   #include<iostream.h>
   class Football
   {
   public:
       Football( ){cout<<"a football is created."<<endl;}
       ~Football( ){tout<<"a football is destroyed."<<endl;}
   };
   void func(int i)
   {
       ______Football f1;
       Football f2;
       cout<<"i="<<i<<endl;
   }
   void main( )
   {
       func(10);
       func(20);
   }

选项

答案static

解析 观察一下输出中对象的构造函数和析构函数的执行次数可以看出,再次进入时某对象没有被构造,亦即该对象在func执行后没有被销毁,再次进入时则不需要重构,可以体现这种功能的标识符只有static。
转载请注明原文地址:https://kaotiyun.com/show/8LVp777K
0

最新回复(0)