单选题下列语句中错误的是( )。Aconst int a;Bconst int a=10;Cconst int*point=0;Dconst int*point=new int(10);
单选题
下列语句中错误的是( )。
A
const int a;
B
const int a=10;
C
const int*point=0;
D
const int*point=new int(10);
参考解析
解析:
A项错误,由关键字const声明符号常量的同时必须为其赋初值。
A项错误,由关键字const声明符号常量的同时必须为其赋初值。
相关考题:
下列语句中,错误的是______。A.const int buffer=256;B.const double*point;C.int const buffer=256;D.double*const point;
下列语句中,错误的是 brA . const int buffer=256; brB . const int temp;brC . const double *point ; brD . const double *rt =new double(5.5);br
有如下类定义: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 . ④
有如下类定义:class Test{public:Test(){ a = 0; c = 0;} // ①int f(int a)const{this-a = a;} // ②static int g(){return a;} // ③void h(intB . {Test::b = b;}; // ④private:int a;static int b;const int c;};int Test::b = 0;在标注号码的行中,能被正确编译的是A . ①B . ②C . ③D . ④
( 18 ) 下列语句中,错误的是A ) const int buffer=256;B ) const double *point;C ) int const buffer=256;D ) double * const point;
有以下类定义 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);
( 28 )有如下程序:#includeiostreamusing namespace std;class MyClass{public:MyClass(int x):val(x) {}void Print() const {cout"const:val="val'\t';}void Print(){cout"val="val't';}private:int val;};int main(){const MyClass obj1(10);MyClass obj2(20);obj1.Print();obj2.Print();return 0;}程序的输出结果是A ) val=10 const:val=20B ) const:val=10 const:val=20C ) const:val=10 val=20D ) val=10 val=20
有如下程序:includeusing namespace std;class MyClass{public:MyClass(int x):val(x 有如下程序: #include<iostream> using namespace std; class MyClass{ public: MyClass(int x):val(x){} void Print()const{cout<<“const:val=”<<<val<<‘\’;} void Print(){cout<<“val=”<<val<<‘t’;} private: int va1; }; int main(){ consA.val=10 const:val=20B.const:val=10 const:val=20C.const:val=10 val=20D.val=10 val=20
main函数中发生编译错误的语句是______。 include class A { public: int a; const i main函数中发生编译错误的语句是______。include<iostream.h>class A{public:int a;const int b;A( ):a(10),b(20){}void fun( )const{cout<<"a="<<a<<"\tb="<<b<<endl;}};void main( ){A obj1;const A*ptr=new A;ptr=obj1;ptr->a=100;ptr->fun( );}
有如下类定义: 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; } //④ }; 其中的四个函数定义中正确的是( )。A.①B.②C.③D.④
下列语句中,错误的是( )。A.const int buffer:256;B.const int temp;C.const double*point;D.const double*rt=new double(5.5);
设int x:,则经过______ 后,语句*px=0;可将x值置为0。A.int*px;B.int const *px=x;C.int* const px=x:D.const int *px=x;
下面的语句中错误的是( )。A.int a=5;int x[a];B.eonst int a=5;int x[a];C.int n=5;int *P=new int[a];D.const int n=5;int *p=new int[a];
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;
下列语句中,错误的是( )。A.const int buffer=256;B.const double*point;C.int const buffer=256;D.double*eonst point:
有如下类定义: class Test { public: Test(){a=0;c=0;} //① int f(int a)const {this->a=a;} //② static int g(){return a;} //③ void h(int b){Test::b=b;}; //④ private: int a; static int b; const int c; }; int Test::b=0; 在标注号码的行中,能被正确编译的是A.①B.②C.③D.④
有如下程序:includeusing namespace std;class MyClass{public: MyClass(int x):val( 有如下程序: #include<iostream> using namespace std; class MyClass{ public: MyClass(int x):val(x) {} void Print() const {cout<<"const:val="<<val<<'\t';} void Print() {cout<<"val="<<val<<'t';} private: int val; }; int main() const MyClass obj1(10); MyClass obi2(20); obj1.Print(); obj2.Print(); return 0; } 程序的输出结果是( )。A.val=10 const:val=20B.const:val=10 const:val=20C.const:val=10 val=20D.val=10 val=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];
有如下类定义和变量定义: class A{ public: A( ){data=0;} ~A( ){ } int GetData( )const{return data;} void SetData(int n){data=n;} private: int data; }; const A a; A b; 下列函数调用中错误的是A.a.GetData( );B. a.SetData(10);C.b.GetData( );D.b.SetData(10);
有如下程序: #inCludeiostream using namespaCe std; Class MyClass{ publiC: MyClass(int X):val(X){} void PrintConst}tout”Const:val=”val’\t’;} void Print{tout”val=”val’\t’;} private: int val; }; int main{ Const MyClass objl(10); MyClass obj2(20); objl.Print; obj2.Print; retum 0; } 执行这个程序的输出结果是( )。A.val=10 Const:val=20B.Const:val=10 Const:val=20C.Const:val=10 val=20D.val=10 val=20
有以下类定义 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)
下面的语句中错误的是A.int a = 5; int x[a];B.const int a = 5; int x[a];C.int n = 5; int *p = new int [a];D.const int n = 5; int *p = new int [a];
单选题下列语句中,错误的是( )。Aconst int buffer=256;Bconst double*point;Cint const buffer=256;Ddouble*const point;