题目内容 (请给出正确答案)
有如下类和对象的定义:class MyHello{public:static string getName() { return "Hello"; }};MyHello my;下列各组语句中,能输出“Hello”的是()。
[主观题]

有如下类和对象的定义:class MyHello{public:static string getName() { return "Hello"; }};MyHello my;下列各组语句中,能输出“Hello”的是()。

A. cout<

B.cout<

C.cout<

D.cout<

提问人:网友weiqian521 发布时间:2024-04-19
参考答案
B
如搜索结果不匹配,请 联系老师 获取答案
更多“有如下类和对象的定义:class MyHello{publi…”相关的问题
第1题
已知有如下类A和类B的声明: class A { public: A(){cout<<"1";} }; b:public a { public: 若用b定义一个对象:b b;,然后程序结束,屏幕上将会输出 。>
点击查看答案
第2题
有如下类和对象的定义:class Constants{public:static double getPI(){return 3.1416;}};Consta

有如下类和对象的定义: class Constants{ public: static double getPI(){return 3.1416;} }; Constants constants; 下列各组语句中,能输出3.1416的是

A.cout<<constants->getPI();和cout<<Constants::getPI();

B.cout<<constants.getPI();和cout<<Constants.getPI();

C.cout<<constants->getPI();和cout<<Constants->getPI();

D.cout<<eonstants.getPI();和cout<<Constants::getPI();

点击查看答案
第3题

有类模板定义如下:template <class type> class Dream{ };下列类对象的定义中正确的是()。

A.Dream a;

B.Dream <class int>a;

C.Dream <int>a;

D.Dream <class type>a;

点击查看答案
第4题
有如下类定义: class B{ public: void fun1(){} private: void fun2(){} protected: void fun3()

有如下类定义:

class B{

public: void fun1(){}

private: void fun2(){}

protected: void fun3(){}

};

class D: public B{

protected: void fun4(){}

};

若obj是类D的对象,则下列语句中不违反访问控制权限的是()。

A) obj. fun1();

B) obj. fun2();

C) obj. fun3();

D) obj. fun4();

点击查看答案
第5题
有如下类和对象的定义: class Constants{ public: static double get PI(){return 3.

有如下类和对象的定义: class Constants{ public: static double get PI(){return 3.1416;} }; Constants constants; 下列各组语句中,能输出3.1416的是

A.cout<<constants->getPI();和cout<<Constants::getPI();

B.cout<<constants. getPI();和cout<<Constants.getPI();

C.cout<<constants->getPI();和cout<<Constants->getPl();

D.cout<<constants. getPI();和cout<<Constants::getPI();

点击查看答案
第6题
有如下类定义:class XX{int xdata:public:xx(int n=0):xdata(n){}}class YY:public XX{int ydata

有如下类定义: class XX{ int xdata: public: xx(int n=0):xdata(n){} } class YY:public XX{ int ydata; public: YY(int m=0,int n=0):xx(m),ydata(n){ } {; YY类的对象包含的数据成员的个数是

A.1

B.2

C.3

D.4

点击查看答案
第7题
有类定义如下:class Type{public:Type(int i=0);Type operator-(int);friend Type operator+(Typ

有类定义如下:

class Type{

public:

Type(int i=0);

Type operator-(int);

friend Type operator+(Type,Type);

private:

int val;

};

若有对象定义Type c1;则下列语句序列中,错误的是

A.Type(3)+c1;

B.c1+Type(3);

C.3-c1;

D.c1-3;

点击查看答案
第8题
有类定义如下:class Type{public:Type(int i=0);Type operator-(int);friend Type operator+(Typ

有类定义如下:

class Type{

public:

Type(int i=0);

Type operator-(int);

friend Type operator+(Type,Type);

private:

int val;

};

若有对象定义Type c1;则下列语句序列中,错误的是

A.Type(3)+c1;

B.c1+Type(3);

C.3-c1;

D.c1-3;

点击查看答案
第9题
有如下类模板定义: template<typename T> class BigNumber{ long n; public: BigNumber(T i):n(i

有如下类模板定义:

template<typename T>

class BigNumber{

long n;

public:

BigNumber(T i):n(i){}

BigNumber operator+(BigNumber B) {

return BigNumber(n+b.n);

}

}

已知b1、b2是BigNumber的两个对象,则下列表达式中错误的是()。

A) b1+b2

B) b1+3

C) 3+b1

D) 3+3

点击查看答案
第10题
有如下类定义: class B { public:void funl{} private:void fun2{} protected:void fun3{} };
class D:public B j protected:void fun4{} }; 若obj是类D的对象,则下列语句中不违反访问控制权限的是()。

A.obj.fun1;

B.obj.fun2;

C.obj.tim3;

D.ohj.fun4;

点击查看答案
第11题
有如下TestA类的定义: public class TestA { static int a=10; } 用该类创建2个对象:testA1和testA2,现将类变量(静态变量)a的数值变为100,则正确的方式是:()。

A.TestA.a=100;

B.testA1.a=100;

C.testA2.a=100;

D.其余选项都不对

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

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

简答题官方微信公众号

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

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

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