题目内容 (请给出正确答案)
[单选题]

有如下的对类“CSample”的定义,其中()在语法上是错误的。 class CSample { int a=51; // CSample(); // public: CSample(int val); // ~ CSample(); // }; ......

A.int a=51;

B.CSample();

C.CSample(int val);

D.~ CSample();

提问人:网友zhaofuke 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
网友答案
查看全部
  • · 有4位网友选择 C,占比40%
  • · 有3位网友选择 B,占比30%
  • · 有3位网友选择 A,占比30%
匿名网友 选择了C
[202.***.***.243] 1天前
匿名网友 选择了C
[152.***.***.231] 1天前
匿名网友 选择了C
[129.***.***.0] 1天前
匿名网友 选择了A
[130.***.***.105] 1天前
匿名网友 选择了A
[4.***.***.120] 1天前
匿名网友 选择了A
[131.***.***.82] 1天前
匿名网友 选择了B
[8.***.***.209] 1天前
匿名网友 选择了C
[92.***.***.159] 1天前
匿名网友 选择了B
[205.***.***.180] 1天前
匿名网友 选择了B
[35.***.***.120] 1天前
匿名网友 选择了C
[202.***.***.243] 1天前
匿名网友 选择了C
[152.***.***.231] 1天前
匿名网友 选择了C
[129.***.***.0] 1天前
匿名网友 选择了A
[130.***.***.105] 1天前
匿名网友 选择了A
[4.***.***.120] 1天前
匿名网友 选择了A
[131.***.***.82] 1天前
匿名网友 选择了B
[8.***.***.209] 1天前
匿名网友 选择了C
[92.***.***.159] 1天前
匿名网友 选择了B
[205.***.***.180] 1天前
匿名网友 选择了B
[35.***.***.120] 1天前
加载更多
提交我的答案
登录提交答案,可赢取奖励机会。
更多“有如下的对类“CSample”的定义,其中()在语法上是错误…”相关的问题
第1题

下述程序中语句完全不正确的一组语句是() class automover { int wheels; float weight; public: void initialize(int, float); int get_wheels(); float get_weight(){return weight;} }; void automover::initialize(int in_wheels, float in_weight) { wheels=in_wheels; weight=in_weight;} int automover::get_wheels(void){ return wheels; } void main() { automover car; automover.initialize(4, 3000.0); //① car.wheels=4; //② car.weight=3000.0; //③ car.initialize(4, 3000.0); //④ cout<<"\nthe car has> <<" wheels."; ⑤ car weighs> <<" pounds."; ⑥ car has> <<" wheels."; ⑦ car weighs> <<" pounds."; ⑧ }> A、①、②、③、④、⑤

B、①、②、③、⑤、⑥

C、②、③、④、⑤、⑥

D、①、②、④、⑦、⑧

点击查看答案
第2题
有 以 下 类 定 义 : class B { protected: int count; public: B(int c):count(c){ }; virtual void Print()=0; }; class D:public B { public: D(int c):B(c){}; void Print(){cout<<count<<endl;} }; void main() { d d(10); ① b*pb="&amp;d;" ② b b(5); ③ pb->Print(); //④ } ①、②、③、④四个语句编译时错误的是( )。

A、D d(10);

B、B *pb=&d;

C、B b(5);

D、pb->Print();

点击查看答案
第3题
类 MyClass 中有下列方法定义: public void testParams(params int[] arr) { Console.Write ("使用 Params 参数!"); } public void testParams(int x,int y) { Console.Write ("使用两个整型参数!"); } 请问上述方法重载有无二义性?若没有,则下列语句的输出为( )。  MyClass x = new MyClass();  x.testParams(0);   x.testParams(0,1);   x.testParams(0,1,2);

A、有语义二义性;

B、使用 Params 参数!使用两个整型参数!使用 Params 参数!

C、使用 Params 参数!使用 Params 参数!使用 Params 参数!

D、使用 Params 参数!使用两个整型参数!使用两个整型参数!

点击查看答案
第4题
已知类MyClass的定义如下:

classMyClass{

public:

voidfunctionl(MyClass&c){out$amp;statievoidfunction2(MyClas&c){cout$amp;voidfunction3(){out$amp;statiCvoidfunction4(){COut$amp;private:

intdata;

}:

其中有编译错误的函数是()。

A.function1

B.function2

C.function3

D.function4

点击查看答案
第5题
有一个抽象类ObjectVolume,如下所示: abstract class ObjectVolume { abstract double getVolume(); //返回物体的体积 } (1)编写球体类,立方体类和圆柱体类,它们是抽象类ObjectVolume的子类。(提示:想一想,这些子类除了要实现父类的抽象方法,也就是计算各自的体积之外,这些子类各自的成员变量什么?) (2)编写一个public类,其中包含main方法和static void get(ObjectVolume obj)方法(可以看到,get方法的形参是抽象类ObjectVolume声明的对象)。 (3)在main方法中,从键盘上输入1(表示球体)、2(表示立方体)、3(表示圆柱体)时,调用get方法可以分别得到球体、立方体、圆柱体的体积。(提示:调用get方法时,实参应该是各个子类对象,这时,实参子类对象传给形参抽象父类对象,则抽象父类对象就是上转型向对象,想一想,为了得到物体的体积,get方法中的语句应该是什么?)
点击查看答案
第6题
已定义基类A和派生类B:class A { ptivate: int x; protected: int y; public: int z; void ShowA( ) { cout << x << y << z << endl; } }; class B : protected A // 保护继承 { private : int a; protected: int b; public: int c; void ShowB( ) { ShowA( ); cout << a << b << c << endl; } }; 再定义B的派生类C:class C : public B { public: int m; void fun( ) { x = 5; y = 5; z = 5; ShowA( ); } // 访问基类A的成员 }; 函数fun( )中错误的语句是( )。

A、x = 5;

B、y = 5;

C、z = 5;

D、ShowA( );

点击查看答案
第7题
在公有继承的情况下,基类非私有成员在派生类中的访问权限是( )。

A、保持不变

B、类外均可访问

C、仅类内能访问

D、不能直接访问

点击查看答案
第8题
假定已有定义“int b[10]; int *pb;”,则不正确的赋值语句为( )。

A、pb=b[5];

B、*pb=b;

C、pb=*b;

D、*bp=&b[5];

E、pb=b;

F、pb=&b[5];

G、pb=new int;

H、pb=new int(5);

I、pb=new int[5];

点击查看答案
第9题
基类的私有成员被派生类公有继承后,在派生类中可以直接访问。
点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信