正确的结构类型说明
正确的结构变量说明
错误的原因是结构中成员类型相同
无意义的说明
第1题:
有如下类定义:
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 次
第2题:
下面结构体的定义语句中,错误的是( )。
A.struct ord{int x;int y;int z;};struct ord a;
B.struct ord{int x;int y;int z;};ord a;
C.struct ord{int x;int y;int z;}a;
D.struct{int x;int y;int z;}a;
第3题:
下面结构体的定义语句中,错误的是
A)struct ord {int x;int y;int z;}; struct ord a;
B)struct ord {int x;int y;int z;} struct ord a;
C)struct ord {int x;int y;int z;} a;
D)struct {int x;int y;int z;} a;
第4题:
有如下程序:
#include<iostream>
#include<cmath>
using std::cout;
class Point{
public:
friend double distance(const Point &p); //P距原点的距离
Point(int xx=0,int yy=0):x(xx),Y(YY){}//①
private:
int x,y;
};
double distance(const Point &p){ //②
return sqrt(P.x*P.x+P.y*P.y);
}
int main(){
Point p1(3,4);
cout<<distance(p1);
return 0; //③
}
下列叙述中正确的是
A.程序编译正确
B.程序编译时语句①出错
C.程序编译时语句②出错
D.程序编译时语句③出错
第5题:
下面结构体的定义语句中,错误的是( )。
A.struct ord{int x;int Y;int Z;};struet ord a;
B.struct ord{int x;int y;int Z;}struct ord a;
C.struct ord{int X;int Y;int Z;}a;
D.struct{int X;int y;int Z;}a;
第6题:
下列语句段中,正确的是( )。
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;};
第7题:
以下正确的函数原型语句是( )。
A、double fun(int x,int y)
B、double fun(int x;int y)
C、double fun(int,int);
D、double fun(int x,y);
第8题:
设有以下说明语句
struct ex
{ int x ; float y; char z ;} example;
则下面的叙述中不正确的是
A.struct结构体类型的关键字
B.example是结构体类型名
C.x,y,z都是结构体成员名
D.struct ex是结构体类型名
第9题:
有以下程序: #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)
第10题:
设有以下C语言说明语句:
struct ex{int x;float y;char z;} example
则下面的叙述中不正确的是(52)。
A.struct是结构体类型的关键字
B.x、y、z都是结构体成员名
C.struet ex是结构体类型
D.example是结构体类型名