网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
Const和ReadOnly?
参考答案
更多 “Const和ReadOnly?” 相关考题
考题
下列符号常量的声明中,不合法的是A.Const a As Single=1.1B.Const a=”0K”C.Const a As Double=Sin(1)D.Const a As Integer=“12”
考题
下列语句中,错误的是______。A.const int buffer=256;B.const double*point;C.int const buffer=256;D.double*const point;
考题
有如下类定义: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 . ④
考题
( 18 ) 下列语句中,错误的是A ) const int buffer=256;B ) const double *point;C ) int const buffer=256;D ) double * const point;
考题
下列语句中错误的是( )。A.const int a;B.const int a=10;C.const int*point=0;D.const int*point=new int(10);
考题
( 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
考题
关于const常量定义,下面正确的使用方式是()
A.const Pi float64 = 3.14159265358979323846const zero = 0.0B.const (size int64 = 1024eof = -1 )C.const (ERR_ELEM_EXIST error = errors.New("element already exists")ERR_ELEM_NT_EXIST error = errors.New("element not exists"))D.const u, v float32 = 0, 3 const a, b, c = 3, 4, "foo"
考题
要禁止修改指针p本身,又要禁止修改p所指向的数据,这样的指针应定义为( )。
A.const char *p=”ABCD”;B.char const *p=”ABCD”;C.char *const p=”ABCD”;D.const char *const p=”ABCD”;
考题
下列语句中,错误的是( )。A.const int buffer:256;B.const int temp;C.const double*point;D.const double*rt=new double(5.5);
考题
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 a As Single=1.1B.Const a="OK"C.Const a As Double=Sin(1)D.Const a As Integer="12"
考题
下列语句中,错误的是( )。A.const int buffer=256;B.const double*point;C.int const buffer=256;D.double*eonst point:
考题
阅读以下说明和C++代码(代码13-1),将应填入(n)处的字句写在对应栏内。【说明】软件设计师东方飞龙利用UML设计了一个迷你小型复数类,其类图如图13-11所示。【代码13-l】/*___________________________________*//********* 文件 MiniComplex. h*********//*___________________________________*/include<iostream>using namespace std;class MiniComplex{(1)://重载流插入和提取运算符(2) ostream operator <<(ostream osObject, const MiniComplex complex){ osObject <<"("<<complex. realPart<<"+"<<complex. imagPart <<"I"<<")";return osObject;}friend (3) operator >>(istream isObject, MiniComplex complex){ char ch;isObject >>complex. realPart >>ch>>complex. imagPart >>ch;return isObject;}MiniComplex(double real=0, double imag=0); //构造函数MiniComplex operator+(const MiniComplex otherComplex)const! //重载运算符+MiniComplex operator--(const MiniComplex otherComplex)const! //重载运算符-MiniComplex operator*(const MiniComplex othmComplex)const; //重载运算符*MiniComplex operator/(const MiniComplex otherComplex)const; //重载运算符/bool perator==(const MiniComplex otherComplex)const; //重载运算符==private:double realPart; //存储实部变量double imagPart; //存储虚部变量};/*_______________________________________________________*//* * * * * * * * *文件 MiniComplex. cpp* * * * * * * * * *//*_______________________________________________________*/include "MiniComplex.h"bool MiniComplex:: perator==(const MiniComplex otherComplex)const{ (1);}MiniComplex:: MiniComplex(double real, double imag){realPart=real;imagPart=imag!}MiniComplex MiniComplex:: operator+(const MiniComplex otherComplex)const{ MiniComplex temp;temp. realPart=realPart+ otherComplex. realPart;temp. imagPart=imagPart+ otherComplex. imagPart;return temp;}MiniComplex MiniComplex::operator--(const MiniComplex otherComplex)const{ MiniComplex temp;temp.realPart=realPart-otherComplex.realPart;temp. imagPart=imagPart-otherCompler.imagPart;return temp;}MiniComplex MiniComplex:: operator*(const MiniComplex otherComplex)const{ MiniComplex temp;temp.realPart=(realPart* otherComplex.realPart)-(imag-Part* otherComplex.imag-Part);temp imagPart=(realPart* otherComplex. imagPart)+(imag-Part *otherComplex.realPart);return temp,}MiniComplex MiniComplex:: operator/(const MiniComplex otherComplex)eonst{ MiniComplex temp;float tt;tt=1/(otherComplex. realPart *otherComplex. realPart+otherComplex. imagPart* other Complex.imagPart);temp. realPart=((realPart* otherComplex.realPart)+(imagPart* otherComplex.imagPart))*tt;temp. imagPart=((imagPart * otherComplex.realPart)-(realPart* otherComplex.imagPart))*tt;
考题
在下列的标识符常量的定义语句中,错误的定义语句是()。A、const double PI=3.14159;B、const int N=20;C、const char ch;D、const bool mark=true;
考题
若有类W说明class W{int a;public:voidfConst(int)const;};,则函数fConst的正确定义是()A、void W::fConst(intk)const{k=a;}B、void W::fConst(intk)const{k=a++;}C、void W::fConst(intk)const{cina;}D、void W::fConst(intk)const{a=k;}
考题
以下各项中,不是字符串常量的是()。A、Const a As Single=10.5B、Const a As Double=Cos(10.5)C、Const a="abc"D、Const a As Integer=10.5
考题
问答题const和readonly有什么区别?
热门标签
最新试卷