计算机二级考试

解析:下列程序的输出结果是( )。    #include<iostre

来源:网考网计算机二级 所有评论

【单选题】下列程序的输出结果是( )。    #include<iostream.h>    class Myclass {     public:Myclass(int i=0,intj=0)      { x=i;       y=j;      }      void show( ) { cout < < "x=" < < x < < " " < "y=" < < y < < end1;}      void show( )const { cout < < "x=" < < " " < < "y=’’ < < y < < end1;}      privated:         int x;    int y;      };     void main( )    { Myclass my1(3,4);     const my2(7,8);     my1.show( );my2.show( );}
A、line 4
B.line 6
C.line 7
D.line 8

网考网参考答案:C
网考网解析:

要为一个新对象分配空间必须执行new Xxx( )调用,new调用执行 以下的操作:①为新对象分配空间并将其成员初始化为0或者null。②执行类体中的初 始化(例如在类中有一个成员声明int a=10;在第一步后a=0,执行到第二步后a=10)。 ③执行构造方法。④变量被分配为一个到内存堆中的新对象的引用。 document.getElementById("warp").style.display="none"; document.getElementById("content").style.display="block"; 查看试题解析出处>>

相关推荐

发布评论 查看全部评论