• 2022-06-08
    下面定义结构体数组的代码段正确的是()。
    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];
  • A

    内容

    • 0

      有以下程序: #include <iostream> #include <cmath> using namespace std; class Distance; class point { public: friend class Distance; Point(int a,int B) { x=a; Y=b; } void Print() { cout<<"X= "<<X<<end1; cout<<"Y= "<<Y<<end1; } private: float X,Y; }; class Distance { public: float Dis(Point &p,Point &q); }; float Distance :: Dis(Point &p,Point &q) { float result; result=sqrt((p.X-q.X)*(p.X-q.X)+(p.Y-q.Y)*(p.Y-q.Y)); cout<<result<<end1; retUrn result; } int main() { Point p(10,10),q(10,30); Distance d; d.Dis(p,q); return 0; } 运行后的输出结果是( )。 A: 10 B: 30 C: 0 D: 20

    • 1

      下面代码中,没有定义内部类或者错误定义了内部类的是()。 A: public Class Line { int length; Class Point {//内部类代码}} B: public Class Line { public Point getPoint() { return new Point(){//内部类代码}; }} C: public Class Line { //外部类代码} Class Point {//内部类代码} D: public Class Line { public int calcLength() { Class Point {//内部类代码} }}

    • 2

      class Person {private int a;public int change(int m){ return m; }}public class Teacher extends Person {public int b;public static void main(String arg[]){Person p = new Person();Teacher t = new Teacher();int i;// point x}}在 // point x安排哪个语句合法?

    • 3

      对于以下的变量定义,表达式______是不正确的。struct { float x, y;} point, *p=&point; A: p->x=2.0 B: (*p).y=3.0 C: point.x=2.0 D: *p->y=3.0

    • 4

      已知 Point类,要求在该类中完成+,- 两种操作符的重载。(重写Point类)class Point{ public: Point(float x=0, float y=0, float z=0): xx(x), yy(y), zz(z){} Point(const Point& p): xx(p.xx), yy(p.yy), zz(p.zz){ } private: float xx, yy, zz;}……