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];
举一反三
- 下列代码中: class Point{ int x,y; public: Point(int a, int b=0); //① Point(Point &aPoint); //②Point(Point *p); //③ 默认的构造函数是 A: ① B: ② C: ③ D: 没有
- 【单选题】设Point为已定义的类,下面声明Point对象a语句正确的是() A. Point a=Point(); B. public Point a; C. Point a=new Point(); D. public Point a=new Point();
- 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(); }}
- 有如下类的定义[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属性值。
- 对于以下的变量定义,表达式______是不正确的。struct { float x, y;} point, *p=&point;
内容
- 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;}……