niusouti.com

有如下程序: #jnClude<iostream> using namespaCe std; Class Part{ publiC: Part(int x=0):val(X){Cout<<val;} ~Part{Cout<<val;} private: int val; t }; Class Whole{ publiC: Whole(int x,int Y,int z=0):p2(x),pl(y),val(z){Cout<<val;} ~Whole{eout<<val;} private: Part pl

题目

有如下程序: #jnClude<iostream> using namespaCe std; Class Part{ publiC: Part(int x=0):val(X){Cout<<val;} ~Part{Cout<<val;} private: int val; t }; Class Whole{ publiC: Whole(int x,int Y,int z=0):p2(x),pl(y),val(z){Cout<<val;} ~Whole{eout<<val;} private: Part pl,p2; int val; }; int main { Whole obj(1,2,3); return 0; } 执行这个程序的输出结果是( )。

A.123321

B.213312

C.213

D.123123


相似考题
更多“有如下程序: #jnClude&lt;iostream&gt; using namespaCe std; Class Part{ publiC: Part(int x ”相关问题
  • 第1题:

    写出下列程序的运行结果【】。 include void func(double x, int &part1, double

    写出下列程序的运行结果【 】。

    include<iostream. h>

    void func(double x, int &part1, double &part2){

    part1=int(x)+500:

    part2=(x+500-part1)*100;

    }

    void main( ){

    int n;

    double x, f;

    x=1001. 0103;

    func (x, n, f):

    cout<<"Part 1="<<n<<" , part2="<<f<<end1

    }


    正确答案:part1=1501 part2=1.03
    part1=1501, part2=1.03

  • 第2题:

    阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。
    【说明】
    以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。




    【Java代码】
    interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}


    答案:
    解析:
    (1)void drawCircle (int radius,int x,int y)
    (2)DrawCircle drawCircle
    (3)super.drawcircle=drawcircle
    (4)drawCircle(radius,x,y)
    (5)new RedCircle()
    (6)new GreenCircle()【解析】
    第一空是填接口里面的方法,在接口的实现里面找,可以发现应该填void drawCircle (int radius,int x,int y)。
    第二空可以根据后面this drawCircle=drawCircle判断,这里应该有一个drawCircle属性,因此应该填)DrawCircle drawCircle。
    第三空这里用super,用super. drawcircle来引用父类的成员。
    第四空调用drawCircle(radius,x,y)方法。
    第五、六空分别创建一个红色圆形对象和一个绿色圆形对象作为Circle里面的实参。

  • 第3题:

    下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

    A.<class 'int'> <class 'float'> <class 'str'>

    B.<class 'float'> <class 'int'> <class 'str'>

    C.<class 'str'> <class 'float'> <class 'int'>

    D.<class 'str'> <class 'int'> <class 'float'>


    C.循环执行1次

  • 第4题:

    Given the following DDL for the PARTS table:CREATE TABLE parts (part_no INT(9) NOT NULL, part_name VARCHAR(24), part_remain INT(9));All part numbers entered will be different and all rows should be displayed in order of increasing part numbers whenever the table is queried. Which of the following create index statements will meet this criteria and require the least amount of storage for the index object?()

    A.CREATE UNIQUE INDEX idx_partno ON parts(part_no)

    B.CREATE UNIQUE INDEX idx_partno ON parts(part_name ASC)

    C.CREATE UNIQUE INDEX idx_partno ON parts(part_name, part_no ASC)

    D.CREATE UNIQUE INDEX idx_partno ON parts(part_no, part_name ASC)


    参考答案:A

  • 第5题:

    阅读下列说明和C++代码,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。
    【说明】
    以下C++代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分类及其关系如图6-1所示。



    【C++代码】
    #include?#include?using?namespace?std;class?DrawCircle?{??????//绘制圆形,抽象类? ? ? public: (1);//定义参数为?int?radius,?int?x,?inty? ?virtual~DrawCircle()?{?}};class?RedCircle:public?DrawCircle?{????//绘制红色圆形? ? ? ? public: void?drawCircle(intradius,?int?x,?int?y)?{cout?<?drawCircle?=?drawCircle;? }? ?virtual~shape()?{?}? public:? ?virtual?void?draw()?=?0;};class?Circle:public?Shape?{????//圆形? ? private:? ? ?int?x,y,radius;? ? public:? Circle(int?x,inty,int?radius,DrawCircle?*drawCircle)? (3)? {? this->x?=?x;? ?this->y?=?y;? ? this->radius?=?radius; }? ? ? public:? void?draw(){? drawCircle?-> (4); }};int?main(){Shape?*redCirclenew?Circle(100,100,10,????(5)????);//绘制红色圆形? Shape?*greenCircle=new?Circle(100,100,10, (6)??);//绘制绿色圆形redCircle >draw();? ?greenCircle?->draw();? ?return?0;}


    答案:
    解析:
    (6)(1)void drawCircle (int radius,int x,int y)
    (2)DrawCircle*drawCircle
    (3)drawcircle
    (4)drawCircle(radius,x,y)
    (5)new RedCircle()
    (6)new GreenCircle()【解析】
    第一空是填接口里面的方法,在接口的实现里面找,可以发现应该填void drawCircle (int radius,int x,int y)。
    第二空可以根据后面this drawCircle=drawCircle判断,这里应该有一个drawCircle属性,因此应该填)DrawCircle drawCircle。
    第三空这里填drawcircle,用-> drawcircle来引用父类的成员。
    第四空调用drawCircle(radius,x,y)方法。
    第五、六空分别创建一个红色圆形对象和一个绿色圆形对象作为Circle里面的实参。