const int buffer=256;
const double*point;
int const buffer=256;
double*const point;
第1题:
有如下类定义:
class AA
{
int a;
public:
int getRef() const{return &a;} // ①
int getvalue() const{return a;} // ②
void set(int n) const{a=n;} // ③
friend void show(AA aa) const {cout< // ④
};
其中的四个函数定义中正确的是
A . ①
B . ②
C . ③
D . ④
第2题:
( 18 ) 下列语句中,错误的是
A ) const int buffer=256;
B ) const double *point;
C ) int const buffer=256;
D ) double * const point;
第3题:
下列语句中错误的是( )。
A.const int a;
B.const int a=10;
C.const int*point=0;
D.const int*point=new int(10);
第4题:
下列语句中,错误的是( )。
A.const int buffer:256;
B.const int temp;
C.const double*point;
D.const double*rt=new double(5.5);
第5题:
下列程序的执行结果为【 】。
include <iostream. h>
class Point
{
public:
Point(double i, double j) { x=i; y=j;}
double Area() const { return 0.0;}
private:
double x, y;
};
class Rectangle: public Point
{
public:
Rectangle(double i, double j, double k, double 1)
double Area() const {return w * h;}
private:
double w, h;
};
Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j).
{
w=k, h=1
}
void fun(Point &s)
{
cout<<s. Area()<<end1;
}
void main( )
{
Rectangle rec(3.0, 5.2, 15.0. 25.0);
fun(rec)
}
第6题:
下列声明语句中没有起到定义作用的是( )。
A.int count;
B.const double pi=3.14159;
C.extern long index;
D.int max(int a,int b){return a>b? a:b;}
第7题:
What do the following declarations mean?
a) const int a;
b) int const a;
c) const int *a;
d) int * const a;
e) int const * a const;
第8题:
下列语句中,错误的是( )。
A.const int buffer=256;
B.const double*point;
C.int const buffer=256;
D.double*eonst point:
第9题:
有以下类定义 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)
第10题:
第11题:
在下列的标识符常量的定义语句中,错误的定义语句是()。
第12题:
const int buffer=-256;
const int temp;
const double*point;
const double*rt=new double(5.5);
第13题:
有如下程序:
#include
using namespace std;
class Complex
{
double re, im;
public:
Complex(double r, double i):re(r), im(i){}
double real() const{return re;}
double image() const{return im;}
Complex& operator +=(Complex a)
{
re += a.re;
im += a.im;
return *this;
}
};
ostream &operator<<(ostream& s,const Complex& z)
{
return s<<'('<
}
int main()
{
Complex x(1, -2), y(2, 3);
cout<<(x += y)<
return 0;
}
执行这个程序的输出结果是
A . (1, -2)
B . (2, 3)
C . (3, 5)
D . (3, 1)
第14题:
有以下类定义 classPoint{ 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<<')'<<endl;} private: int_x_y; }; 下列语句中会发生编译错误的是
A.Pointpt;pt;Print();
B.const Point pt;pt.Print();
C.Pointpt;pt.Move(1,2);
D.const Point pt;pt.Move(1,2);
第15题:
下列的符号常量定义中,错误的定义是( )。
A、const M=10;
B、const int M=20;
C、const char ch;
D、const bool mark=true;
第16题:
有如下程序:
#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.程序编译时语句③出错
第17题:
已知有定义:
const int D=5;
int i=1;
double f=0.32;
char c=15;
则下列选项错误的是
A.++i;
B.D--;
C.c++;
D.--f;
第18题:
下列符号常量的声明中,______ 是不合法的。
A.Const a As Single =1.1
B.Const d As Integer =“12”
C.Const b As Double = Sin(1)
D.Const c As String = “OK”
第19题:
下列符号常量的声明中,不合法的是
A.Const a As Single=1.1
B.Const a="OK"
C.Const a As Double=Sin(1)
D.Const a As Integer="12"
第20题:
下面的语句中错误的是( )。
A.int a=5;int x[a];
B.const int a=5;int x[a];
C.int n=5;int *p=new int[n];
D.const int n=5;int *p=new int[a];
第21题:
第22题:
下列符号常量的声明中,()是不合法的。
第23题:
以下各项中,不是字符串常量的是()。
第24题:
const int buffer=256;
const double*point;
int const buffer=256;
double*const point;