网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

对于以下的变量定义,表达式______是不正确的。 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


参考答案和解析
char ch='m';
更多 “对于以下的变量定义,表达式______是不正确的。 struct { float x, y; } point, *p=point;A.p->x=2.0B.(*p).y=3.0C.point.x=2.0D.*p->y=3.0” 相关考题
考题 设已有定义: float x; 则以下对指针变量 p 进行定义且赋初值的语句中正确的是A)float *p=1024;B)int *p=(float)x;C)float p=x;D)float *P=x;

考题 设已有定义:float x;则以下对指针变量p进行定义且赋初值的语句中正确的是( )。A.float *p=1024;B.int *p=(float x);C.float p=x;D.float *P=x;

考题 若有以下说明和定义语句,则变量w在内存中所占的字节数是 【19】 。union aa {float x; float y; char c[6]; };struct st{ union aa v; float w[5]; double ave; } w;

考题 以下对结构体类型变量的定义中,不正确的是A.typedef struct aa{ int n;float m;}AA;AA tdl;B.#define AA struct aaAA{ int n;float m;} tdl;C.struct{ int n;float m;} aa;struct aa tdl;D.struct{ int n;float m;} tdl;

考题 有如下类定义:class Point{int x_, y_;public:Point():x_(0), y_(0){}Point(int x, int y = 0):x_(x),y_(y){}};若执行语句Point a(2), b[3] , *c[4];则 Point 类的构造函数被调用的次数是A . 2 次B . 3 次C . 4 次D . 5 次

考题 下列语句段中,正确的是( )。A.struct{int x;float y;int a[2];unsigned b[3];char name[10];};B.struct stu{unsigned a[3];unsigned b[4];}x;int*p=x.a;C.struct stu{int a;float x[4];}y={1,1.0};float data=y.x;D.struct nd{int a,b;unsigned c[2]=5;};

考题 下面程序的输出结果是【】。include include class point{double x; double y; 下面程序的输出结果是【 】。include <iostream.h>include <math.h>class point{double x;double y;public:point(double a, double b){x=a;y=b;}friend double distance(point a, point b) ;};double distance(point a, point b){return sqrt ((a. x-b.x) * (a. x-b.x)+ (a. y-b. y) * (a. y-b. y) );}void main(){point p1(1,2);point p2(5,2);cout<<distance(p1,p2)<<end1;}

考题 阅读下列C++程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】Point是平面坐标系上的点类,Line是从Point派生出来的直线类。include <iostream.h>class Point{public:Point (int x, int y) ;Point (Point p) ;~Point();void set (double x, double y) ;void print();private:double X,Y;};Point::Point (int x, int y) //Point 构造函数{X=x; Y=y; }Point::Point ( (1) ) //Point 拷贝构造函数{X=p.X; Y=p.Y;}void Point::set (double x, double y){X=x; Y=y; }void Point::print(){cout<<' ('<<X<<","<<Y<<") "<<endl; }Point::~Point(){cout<<"Point 的析构函数被调用! "<<endl;class Line: public Point{public:Line (int x, int y, int k) ;Line (Line s) ;~Line();void set (double x, double y, double k)void print();private:double K;};(2)//Line 构造函数实现{ K=k;}(3)//Line 拷贝构造函数实现{K=s.K;}void Line::set (double x, double y, double k){ (4);K=k;}void Line::print(){cout<<" 直线经过点";(5);cout<<"斜率为: k="<<K<<endl;}Line: :~Line(){cout<<"Line 析构函数被调用! "<<endl;}void main(){Line 11 (1,1,2) ;11 .print();Linel2 (11) ;12.set (3,2,1) ;12.print();}

考题 下面程序的输出结果是【】。 inclde include using namespace std; class point { 下面程序的输出结果是【 】。inclde<iostreamn>include<math>using namespace std;class point{private:double x;double y;public:point(double a,double b){x=a;y=b;}friend double distance(point a,point b);};double distance(point a,point b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int main(){point p1(1,2);point p2(5,2);cout<<distalice(p1,p2)<<endl;return 0;}

考题 有以下程序: include using namespace std; class Point' { public: void SetPoint( 有以下程序: #include <iostream> using namespace std; class Point' { public: void SetPoint(int x,int y); void Move(int xOff,int yOff); int GetX() { return X; } int GetY() { return Y; } private: int X,Y; }; void Point::SetPoint(int x, int y) { X=x; Y=y; } void Point: :Move(int xOff, int yOff) X+=xOff; Y+=yOff; } int main () { Point p1; p1.SetPoint(1,2); p1.Move (5, 6); cout<<"Point1 is ("<<p1.GetX()<<','<<p1.GetY()<<")"<<end1; return 0; } 执行后的输出结果是( )。A.Point1 is (6,8)B.Point1 is (1,2)C.Point1 is (5,6)D.Point1 is (4,4)

考题 下面程序的输出结果是()。includeincludeusing namespace std;class point{p 下面程序的输出结果是( )。 #include<iostream> #include<math.h> using namespace std; class point { private: double x; double y; public: point(double a,double b) { x=a; y=b; } friend double distances(point a,point b); }; double distances(point a,point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } int main() { point p1(1,2); point p2(5,2); cout<<distances(p1,p2)<<end1; return 0; }A.2B.4C.8D.16

考题 以下对结构体类型变量的定义中,不正确的是( )A.typedef struct aa { int n; float m; }AA; AA tdl;B.#define AA struct aa AA{ int n; float m; }tdl;C.struct { int n; float m; }aa; struct aa tdl;D.struct { int n; float m, }tdl;

考题 有如下程序:include using namespace std;class point{int x, y;public:point( int v 有如下程序:#include <iostream>using namespace std;class point{ int x, y;public: point( int vx, int vy ) { X=vx; y=vy; } point() { x=0; y=0; } point operator+ ( point p1 ) { point p; int px = x + p1.x; int py = y+ p1.y; return point( px, py ); } point operator-( point p1 { point p; int px = x - p1.x; int py = y - p1.y; return point( px, py ); } void print() { cout<<x<<","<<y<<end1; }};int main(){ point p1( 10, 10 ), p2( 20, 20 ); p1 = p1 + p2; p1.print(); return ();}执行后的输出结果是( )。A.10, 10B.20, 20C.10, 20D.30, 30

考题 l设已有定义:floatx;,则以下对指针变量p进行定义且赋初值的语句中正确的是( )。A.float*p=S l设已有定义:floatx;,则以下对指针变量p进行定义且赋初值的语句中正确的是( )。A.float*p=&x;B.int*p-(float)x;C.float p=&x;D.float*p=1024;

考题 有如下类定义:class Point{int x__, y__;public:Point(): x_(0), y_(0) {}Point(int x, int y =0): x_(x), y_(y) {}若执行语句Point a(2),b[3], *c[4];则Point 类的构造函数被调用的次数是( )。A.2次B.3次C.4次D.5次

考题 有以下程序:include include using namespace std;class point{private:doubl 有以下程序:#include <iostream>#include <math>using namespace std;class point{private: double x; double y;public: point(double a, double b { x=a; y=b; friend double distance (point a, point b ; };double distance(point a, point b return sqrt((a. x-b. x )*(a. x -b. x )+ (a. x -b. x)*(a. x-b. x));}int main (){ point p1 (1,2); point p2(5,2); cout<<distance (p1, p2)<<end1; return 0;} 程序运行后的输出结果是A.1B.5C.4D.6

考题 有如下程序:include using namespace std;class point{intx,y;public:point( int vx, 有如下程序:#include <iostream>using namespace std;class point{ int x, y;public: point( int vx, int vy ) { x = vx; y = vy; } point ( ) x = 0; y= 0; } point operator+( point p1 ) { point p; int px = x+ p1.x; int py = y + p1.y; return point( px, py ); point operator-( point p1 ) { point p; int px = x -p1.x; int py = y - p1.y; return point ( px, py ); } void print() { cout<<x<<" , "<<y<<end1; }};int main (){ point p1(10, 10 ), p2( 20, 20 ); p1 = p1 - p2; p1.print (); return 0;} 执行后的输出结果是A.10,10B.20,20C.10,20D.30,30

考题 设已有定义:float x;,则以下对指针变量P进行定义且赋初值的语句中正确的是( )。A.int*p=(float)x;B.float*p=x;C.float p=x;D.float=1024;

考题 有以下程序:include include using namespace std;class point{private: doub 有以下程序: #include <iostream> #include <math> using namespace std; class point { private: double x; double y; public: point(double a,double b) { x=a; y=b; } friend double distance(point a,point b) ; }; double distance(point a,point b) { return sqrt ((a.x-b.x)* (a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } int main ( ) { point pl(1,2); point p2 (5, 2); cout<<distance (pl,p2) <<end1; return 0; } 程序运行后的输出结果是( )。A.1B.5C.4D.6

考题 请教:2016年计算机二级C++基础练习二简答题2如何解答? 有以下两个程序,分析它们的执行结果有什么不同。程序1:#includeclass Point{int x,y;public:Point(){x=y=0;}Point(int i,int j){x=i;y=j;}Point operator+(Point);void disp() ( cout”(”}Point Point::operator+(Point P){this-x+=P.x; this-y+=p.y;return *this;}void main(){Point pl(2,3),p2(3,4),p3;cout”p1:”;p1.disp();cout”p2:”;p2.disp();p3=pl+p2;cout”执行p3=p1+p2后”cout”p1:”,p1.disp();cout”p2:”;p2.disp();cout”p3:”;p3.disp();}程序2:#includeclass Point{int x,Y;public:Point(){x=y=O;}Point(int i,int j){x=i,y=j;}Point operator+(Point);void disp f){cout ”(”}Point Point::operator+(Point P){Point s;s.x=x+p.x; s.y=y+p.y;return s;}void main(){Point pl(2,3),p2(3,4),p3;cout”p1:”;p1.disp();cout”p2:”;p2.disp();p3=pl+p2;cout”执行p3=p1+p2后”cout”p1:”;p1.disp();cout”p2:”;p2.disp();cout”p3:”;p3.disp();}

考题 有如下程序: include using namespace std; class point {int x,y; public:point( i 有如下程序: #include <iostream> using namespace std; class point { int x, y; public: point( int vx, int vy ) { x = vx; y = vy; } point ( ) { x = 0; y = 0; } point operator+( point pl ) { point p; int px = x + p1.x; int py = y + p1.y; return point( px, py ); } point operator-( point p1 ) { point p; int px = x - p1.x; int py = y - p1.y; return point( px, py ); } void print() { cout<<x<<", "<<y<<end1; } }; int main () { point pl ( 10, 10 ), p2 ( 20, 20 ); p1 = p1 + p2; p1.print (); return 0; } 执行后的输出结果是( )。A.10,10B.20,20C.10,20D.30,30

考题 有以下类定义: class Point { public: Point(int x=0,int y=0){_x=x; _y=y;} void Move(int x Off, int y Off) {_x+=x Off; _y+=y Off; } void Print() const { cout <<'(' << _x << ',' << _y << ')'<< end 1;} private: int _x,_y; }下列语句中会发生编译错误的是______。A.Point pt; pr. Print();B.const Point pt; pt. Print();C.Point pt; pt. Move(1,2);D.const Point pt; pt. Move(1,2);

考题 下列语句段中,正确的是( )。A.struct { int x; float y; int a[2]; unsigned b[3]; char name[ 10]; };B.struct stu { unsigned a[3]; unsigned b[4]; }x; int *p= x.a;C.street stu { int a; float x[4]; }y={1,1.0}; float data=y.x;D.struct nd {int a,b; unsigned c[2]=5; };

考题 有以下类定义 class Point{ public: Point{int x = 0, int y=0) {_x = x; _y = y;} void Move int xoff, int yoff) {_x +=xoff;_y+=yoff;} void Print() const {cout<<'('<<_x<<','<<_y<<')' << end1;} private: int_x,_y; }; 下列语句中会发生编译错误的是A.Point pt;pt.Print();B.const Point pt;pt.Print();C.Point pt;pt.Move(1, 2);D.const Point pt;pt.Move(1, 2)

考题 有以下程序:includeincludeusingnamespacestd;classDistance;classpoint{pub 有以下程序: #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.10B.30C.0D.20

考题 若已定义   struct num{    int a;    int b;   float f;  } n={1,3,5.0};  struct num *p=n;  则表达式p-b/n.a*++p-b的值是  ①  ,表达式(*p).a+p-f的值是  ②  。

考题 有以下说明语句:struct point{int x;int y;}p;则正确的赋值语句是()A、point.x=1;point.y=2;B、point={1,2};C、p.x=1;p.y=2;D、p={1,2};

考题 单选题有以下说明语句:struct point{int x;int y;}p;则正确的赋值语句是()A point.x=1;point.y=2;B point={1,2};C p.x=1;p.y=2;D p={1,2};