题目内容 (请给出正确答案)
[主观题]

有如下类和对象的定义: 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();

提问人:网友yty118 发布时间:2022-01-06
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“有如下类和对象的定义: class Constants{ p…”相关的问题
第1题
设有如下程序: #include <iostream> using namespace std; class A { public:int i;display(){co

设有如下程序: #include <iostream> using namespace std; class A { public: int i; display() { cout<<"class A\n"; } }; class B { public: int i; display() { cout<<"class B\n"; } }; class C : public A, public B { int j; public: int i; show () { j = i * i; display(); } }; int main() { C demo; demo.show(); return O; } 则主程序运行时将()。

A.因为变量i的重复定义而报错

B.因为对象demo间接调用display()函数时产生二义性而报错

C.因为类定义的语法错误而不能运行

D.没有语法错误,能够正常输出结果

点击查看答案
第2题
已知有如下类A和类B的声明: class A { public: A(){cout<<"1";} }; b:public a { public: 若用b定义一个对象:b b;,然后程序结束,屏幕上将会输出 。>
点击查看答案
第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 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();

点击查看答案
第5题
有如下类定义: 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();

点击查看答案
第6题
有类定义如下: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;

点击查看答案
第7题
有如下类定义: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

点击查看答案
第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题
有如下类定义:class Test { private int x; public int y; public void setX (int m) {x=m;} pub

有如下类定义: class Test { private int x; public int y; public void setX (int m) {x=m;} public int getX() {return x;} }现用Test t=new Text();生成一个对象t,则如下语句中,错误的是()。

A.t.x=10;

B.t.y=10;

C.t. setX(10);

D.int m=t.getX();

点击查看答案
第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;

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

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

简答题官方微信公众号

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

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

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