• 2022-05-31
    有以下定义: class Box{ int width,length,height; public: void set(int x=0,int y=0,int z=0) {width=x;length=y;height=z;} }; Box *box; 则以下哪种使用是正确的___
  • box->set(1,2);

    举一反三

    内容

    • 0

      ‏类A有3个int型成员变量a、b、c,则( )是类A的正确构造方法。​ A: void A(){a=0; b=0; c=0; } B: public void A(){ a=0; b=0; c=0;} C: public int A (int x, int y, int z){ a=x; b=y; c=z; } D: public A(int x,int y, int z) { a=x; b=y; c=z; }

    • 1

      【多选题】已知代码如下 class Rectangle { private int width, height; public void setSize(int width, int height) { this.width = width; this.height = height; } } 下面哪些代码重载 setSize 方法 (10.0分) A. protected void setSize(int width, int height) { this(width, height) } B. public void setSize(int width, float height) { this.width = width; this.height = (int)height; } C. protected void setSize(int width) { this.width = width; } D. public void setSize(int height, int width) { this.width = width; this.height = height; }

    • 2

      下面类的索引定义或使用正确的是()。 A: class MyClass{ int x; int y; public int this[int index] { get{ if (index==0) return x; else return y; }}} B: class MyClass{ int x; int y; public int this[int index] { set{ if (index==0) x=value; else y=value; }}} C: class MyClass{ int x; int y; public int INDEX[int index] { get{ if (index==0) return x; else return y; } set{ if (index==0) x=value; else y=value; }}} D: class MyClass{ int x; int y; public int this[int index] { get{ if (index==0) return x; else return y; } set{ if (index==0) x=value; else y=value; }}}

    • 3

      public void setBounds(int x,int y,int width,int height):移动组件并调整其大小。由 x 和 y 指定左上角的新位置,由 width 和 height 指定新的 。

    • 4

      以下选项错误的是 A.main() { int x,y,z; x=0;y=x-1; z=x+y;} B.main() { int x,y,z; x=0,y=x+1; z=x+y;} C.main() { int x;int int y; x=0,y=x+1; z=x+y;} D.main() { int x,y,z; x=0;y=x+1; z=x+y,}