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

下面是类Shape的定义:class Shape{public:virtual void Draw()=0;}下列关于Shape类的描述中,正确

下面是类Shape的定义: class Shape{ public: virtual void Draw()=0; } 下列关于Shape类的描述中,正确的是()。

A.类Shape是虚基类

B.类Shape是抽象类

C.类Shape中的Draw函数声明有误

D.语句“Shape s;”能够建立Shape的一个对象s

提问人:网友gdsdmsj 发布时间:2022-01-06
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“下面是类Shape的定义:class Shape{publi…”相关的问题
第1题
(12 ) “ 图形 ” 类 Shape 中定义了纯虚函数 CalArea() ,“ 三角形 ” 类 Triangle 继承了类Shape

(12 ) “ 图形 ” 类 Shape 中定义了纯虚函数 CalArea() ,“ 三角形 ” 类 Triangle 继承了类Shape ,请 将

Triangle 类中的 CalArea 函数补充完整。

class Shape{

public:

virtual int CalArea()=0;

}

class Triangle: public Shape{

public:

Triangle{int s, int h}: side(s),height(h) {}

【 12 】 { return side*height/2 ; }

private:

int side;

int height;

};

点击查看答案
第2题
下面是一个类的定义,试将程序补充完整。class A{String s;____int a=66;A(String sl){s=sl;}stati

下面是一个类的定义,试将程序补充完整。

class A{

String s;

____int a=66;

A(String sl){

s=sl;

}

static int geta(){

return a;

}

}

点击查看答案
第3题
已知: abstract class Shape { private int x, y; void setLocation(int x, int y) { this.x = x

已知: abstract class Shape { private int x, y; void setLocation(int x, int y) { this.x = x; this.y = y; } abstract void draw(); } class Circle extends Shape { void draw() {} } class Test { public static void main(String[] args) { _________________ } } 下面哪段代码在横线处是合法的

A、Shape s = new Shape(); s.setLocation(1,1); s.draw();

B、Circle c = new Shape(); s.setLocation(1,1); s.draw();

C、Shape s = new Circle() s.setLocation(1,1); s.draw();

D、Shape s = new Circle() s.Shape.setLocation(1,1); s.Shape.draw();

点击查看答案
第4题
在Java 语言中,有如下的类定义: abstract class Shape{ abstract void draw(); } class Squar

A.一切成功编译

B.Shape可以编译,Square不能编译

C.Square可以编译,Shape不能编译

D.Square,Shape都不能编译

点击查看答案
第5题
下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。define MAXSIZE 100 templa

下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。

define MAXSIZE 100

template <class T>

class Stack

{

T s[MAXSIZE];

int top;

public:

stack()

{

top=1;

}

void push(T newValue)

{

if(top<MAXSIZE)

{

top=top+1;

s[top]=newValue;

}

else

cout<<"堆栈满,无法进栈"<<end1;

}

void pop();

};

【 】

{

if(top>1)

{

cout<<s[top]<<end1;

top=top-1;

}

else

cout<<"堆栈空! "<<end1;

}

点击查看答案
第6题
完成下面类中成员函数的定义。 #include ...

完成下面类中成员函数的定义。 #include <iostream.h> class vehicle {protected: int size; int speed; public: void set(int s){speed=s;} _____get(){return speed/10;} }; class car:public vehicle { public: int get(){return speed;} }; class truck:public vehicle { public: int get(){return speed/2;} }; int max(vehicle &v1,vehicle &v2) { if(v1.get()>v2.get()) return 1; else return 2; } void main() { truck t; car c; t.set(160); c.set(80); cout< <max(t,c)> < <endl; 此结果输出为2>

点击查看答案
第7题
完成下面类中成员函数的定义。 #include ...

完成下面类中成员函数的定义。 #include <iostream> #include <string> using namespace std; class str {private: char *st; public: str(char *a) {set(a); } str & operator=(str &a) {delete st; set(a.st); return *this; } void show(){cout< <st> < <endl;} ~str(){delete st;} void set(char *s) 初始化st {_____ strcpy(st,s); } }; main() {str s1("he"),s2("she"); s1.show(),s2.show(); s2="s1;">

点击查看答案
第8题
【单选题】6.3 若有如下程序: class Teacher{ String name="李";} class Student{ void show(Teach

【单选题】6.3 若有如下程序: class Teacher{ String name="李";} class Student{ void show(Teacher t){System.out.print(t.name);}} class Main{ public static void main(String []args){ Student s = new Student(); s.show(new Teacher());}} 则下面描述正确的是()

A、System.out.print(t.name);语句有语法错误

B、Teacher类的定义有错误,因为缺成员方法

C、s.show(new Teacher());语句有语法错误

D、程序运行结果显示“李”

点击查看答案
第9题
根据下面类中Give 函数的原型和注释写出它的类外定义。class Strings {char *s; // 指向动态分

根据下面类中Give 函数的原型和注释写出它的类外定义。

class Strings {

char *s; // 指向动态分配的字符串数组空间

int n; // 记录字符串长度

public:

Strings(char*str); // 构造函数,利用str 字符串长度初始化n,

// 利用str 字符串初始化s 所指的字符串空间

Strings(Strings& str); // 拷贝构造函数

Strings& Give(Strings& str); // 实现str 赋值给*this 的功能并返回*this

Strings Uion(Strings& str); // 实现*this 和str 中的字符串合并的

// 功能,把合并结果存入临时对象并返回

int Lenth() {return n;} // 返回字符串长度

void Print() {cout<<s<<endl;} // 输出字符串

};

点击查看答案
第10题
下面哪个是用来定义类的关键字:

A.continue

B.class

C.CLASS

D.yield

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

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

简答题官方微信公众号

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

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

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