更多"设有定义: class C public: int ValUe;"的相关试题:
[单项选择]设有定义:
class C
public:
int value;
…
;
int x,*p;
则以下引用形式中,正确的是
A. x=value;
B. x=C::value;
C. p=&value
D. p=C::value
[填空题]有如下定义:
class MA
int value;
public:
MA(int n=0):value(n)
;
MA*ta,tb;
其中MA类的对象名标识符是______。
[填空题]有如下定义:
class MA{
int value ;
public:
MA(int n=0)。value(n){}
};
MA*ta,tb
其中MA类的对象名标识符是______。
[单项选择]阅读下列代码后
public class Person
int art[]=new int[10];
public static void main(String args[])
System.out.println(arr[1]);
正确的说法是( )。
A. 编译时将产生错误
B. 编译时正确,运行时将产生错误
C. 输出零
D. 输出空
[单项选择]阅读下列代码后
public class Person
int arr[]=new int[10];
public static void main(String args[])
System.out.println(arr[1]);
正确的说法是______。
A. 编译时将产生错误
B. 编译时正确,运行时将产生错误
C. 输出零
D. 输出空
[单项选择]阅读下面的程序:
public class Person
int arr[]=new int[10];
public static void main(String args[])
System.out.println(arr[1]);
正确的说法是______。
A. 编译时将产生错误
B. 编译时正确,运行时将产生错误
C. 输出为0
D. 输出为空
[单项选择]有如下类定义:
class AA
int a;
public :
int getRef( )const t 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. ④
[单项选择]有如下类定义:
class AA
int a;
public:
int getRef( )constreturn &a; //①
int getValue( )constreturn a;) //②
void set(int n)consta=n; //③
friend void show(AAaa)constcout<<a; //④
;
其中的四个函数定义中正确的是
A. ①
B. ②
C. ③
D. ④
[单项选择]有如下类定义:
class AA
int a;
public:
int getRef( )eonstreturn &a; //①
int getValue( )constreturn a; //②
vold set(int n)eonsta=n; //③
friend void show(AA a
A. eonsttout<<a; //④
B. ②
C. ③
D. ④
[填空题]有如下定义:
class MA{
int value;
public:
MA(int n=0):value(n){}
};
MA*ta,tb;
其中MA类的对象名标识符是______。
[单项选择]设有以下类和对象的定义:
class A
public:
int m;
…
;
A k1,k2,*p1,* p2;
则下面针对成员变量m的引用,错误的是
A. k1.m=1
B. k2->m=2
C. p1->m=3
D. (*p2).m=4
[单项选择]阅读下面的程序:
public class Person
int arr[ ]=Hew int[10];
public static void main(String args[ ])
System.out.println(arr[1]);
正确的说法是______。
A. 编译时将产生错误
B. 编译时正确,运行时将产生错误
C. 输出为0
D. 输出为空
[单项选择]有如下类定义:
class MyBase
int k;
public:
MyBase(int n=0):k(n)
int value( )const return k;
;
class MyDerived: MyBase
int j;
public:
MyDerived(int i):j(i)
int getK( )const return k;
int getJ( )const return j;
;
编译时发现有一处语法错误,对这个错误最准确的描述是( )。
A. 函数getK试图访问基类的私有成员变量k
B. 在类MyDerived的定义中,基类名MyBase前缺少关键字public、protected或private
C. 类MyDerived缺少一个无参的构造函数
D. 类MyDerived的构造函数没有对基类数据成员k进行初始化
[单项选择]下面程序段的输出结果为
public class Test
int a,b;
Test( )
a=100;
b=200;
Test(int x,int y)
a=x;
b=y;
public static void main(String args[])
Test Objl=new Test(12,45);
System.out.println("a="+objl.a+" b="+Objl.b);
Test Obj2=new Test( );
System.out.println("a="+Obj2.a+" b="+Obj2.b);
A) a=100 b=200
a=12 b=45
B) a=12 b=45
a=100 b=200
C) a=12 b=200
a=100 b=45
D) a=100 b=45
a=12 b=200
[单项选择]有如下类定义:
class Foo
public:
Foo(int v):value(v) //①
~Foo( ) //②
private:
Foo( ) //③
int value=0; //④
;
其中存在语法错误的行是
A. ①
B. ②
C. ③
D. ④
[单项选择]给出下列的程序,其叙述正确的是( )。
public class Man
static int arr[]=new int[10];
public static void main(String args[])
System. out. println (arr[1=];
A. 编译时将发生错误
B. 编译时正确但是运行时出错
C. 输出为0
D. 输出为null