• 2022-06-08
    下列代码中: class Point{ int x,y; public: Point(int a, int b=0); //① Point(Point &aPoint); //②Point(Point *p); //③ 默认的构造函数是
    A: ①
    B: ②
    C: ③
    D: 没有
  • D

    举一反三

    内容

    • 0

      下列对指针变量定义正确的是___________。 A: int Point B: int *Point C: int &Point D: int @Point

    • 1

      8.5 阅读程序,写出运行结果 class Point{ int x=1; static int y=2; public void show(){System.out.println(x+","+y); }} public class tempDemo{ public static void main(String []args){ Point p1=new Point();p1.show(); p1.x=2;p1.y=3; Point p2=new Point();p2.show(); p1.show(); p1.y=5; p2.show(); }}

    • 2

      执行如下语句[br][/br]class point {[br][/br]private:[br][/br] int x_, y_;[br][/br]public:[br][/br] point( ) : x_(0), y_(0) { }[br][/br] point(int x, int y = 0) : x_(x), y_(y) { }[br][/br]};[br][/br]point a(2), b[3], *c[4];[br][/br]则point类的构造函数被调用的次数是______。 A: 2次 B: 3次 C: 4次 D: 5次

    • 3

      下面定义结构体数组的代码段正确的是()。 A: struct POINT{ public double x;//横坐标 public double y;//纵坐标}POINT[] p;p=new POINT[100]; B: struct POINT{ public double x;//横坐标 public double y;//纵坐标}POINT p[100]; C: struct POINT{ public double x;//横坐标 public double y;//纵坐标}POINT p[]=new POINT[100]; D: struct POINT{ public double x;//横坐标 public double y;//纵坐标}POINT p=new POINT[100];

    • 4

      有如下类的定义[br][/br] public class Point { int x;[br][/br] int y;[br][/br] public void show(){ System.out.println("x="+x+",y="+y)[br][/br] }[br][/br] public Point(){[br][/br] }[br][/br] public Point(int x , int y){ this.x = x;[br][/br] this.y = y;[br][/br] }[br][/br] } Point p1 = new Point(); Point p2 = new Point(); Point p3 = new Point(1,1); 关于创建的对象说法不正确的是() A: p1==p2的值是true B: p1.show()的输出结果是x=0,y=0 C: p3.show()输出的结果是x=1,y=1 D: p1.x = 10,是将p1对象的x属性赋值为10,不能改变p2和p3对象的x属性值。