首页 试题详情
问答题

阅读下列说明和C++-代码,将应填入 (n) 处的字句写在答题纸的对应栏内。 【说明】 某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰( Decorator)模式实现打印发票的功能,得到如图5-1所示的类图。 【C++代码】 #include <iostream> using namespace std; class Invoice{ public: (1) { cout<<"This is the content of the invoice!"<<endl; } }; class Decorator : public Invoice { Invoice *ticket; public: Decorator(lnvoice *t) { ticket = t; } void printInvoice( ){ if(ticket != NULL) (2); } }; class HeadDecorator : public Decorator{ public: HeadDecorator(lnvoice*t): Decorator(t) { } void printInvoice( ) { cout<< "This is the header of the invoice! "<< endl; (3) ; } }; class FootDecorator : public Decorator{ public: FootDecorator(Invoice *t): Decorator(t) { } void printlnvoice( ){ (4) ; cout<< "This is the footnote of the invoice!"<< endl; } }; int main(void) { Invoice t; FootDecorator f(&t); HeadDecorator h(&f); h.printInvoice( ); cout<<”------------------------”<<endl; FootDecorator a(NULL) ; HeadDecorator b( (5) ); b.printInvoice( ); return 0; } 程序的输出结果为: This is the header of the invoice! This is the content of the invoice! This is the footnote of the invoice! ---------------------------- This is the header of the invoice! This is the footnote of the invoice!

正确答案:A (备注:此答案有误)

相似试题

  • 问答题

    阅读以下说明,回答问题1至问题2,解答填入答题纸对应的解答栏内。【说明】某留言系统采用ASP+Access开发,其后台管理登录页面如图4-1所示。【问题1】(9分)以下是该后台管理登录页面login.asp的部分代码,请仔细阅读该段代码,根据图4-1 (1)~(9)的空缺代码补齐。【问题2】(6分)1.在登录页面 login.asp 中通过<!--#include file=“bbb.asp”-->导入了bbb.asp的代码,以下是bbb.asp的部分代码,请仔细阅读该段代码空缺代码补齐。

    答案解析

  • 问答题

    试题六(共 15 分)阅读下列说明 C++代码,填补代码中的空缺,解答填入答题纸的对应栏内。【说明】以下 C++代码实现一个简单的聊天室系统(ChatRoomSystem),多个用户 (User)可以向聊天室(ChatRoom)发送消息,聊天室消息展示给所有用户。 类图如图 6-1 所表示。 【C++代码】#include<iostream>#include <string> using namespace std; class User {private:string name; public:User(string name){ (1) =name;}~User(){} void setName(string name) {this->name=name; } string getName(){return name;}void sendMessage(string message); }; class ChatRoom { . public:static void showMessage(User* user, string message) { cout<<[<<

    答案解析

  • 问答题

    阅读下列说明,回答问题1 问题2,解答填入答题纸的对应栏内。【说明】某公司用ASP+Access 数据库开发了学生管理系统,用户登录界面如图4-1 所示:【问题1】(每空1 分,共11 分)下面是该系统用户登录界面login.asp 的部分代码,其中验证码使用verycode.asp 文件生成。请根据题目说明,补充完成。 【问题2】(每空2 分,共4 分)下面是登录系统中check.asp 文件的部分代码,请根据login.asp 代码其补充完整。 <%username=trim(request(user_name))password=trim(request(user_pwd))set rs=server.createobject(adodb.recordset)sql=select * from admin where username=&username& andpassword=&md5(password)&(12).open sql,conn,1,3if rs.eof thenResponse.write <center>&username&用户名或密码错误,请重新输

    答案解析

  • 问答题

    阅读下列说明,回答问题1问题2,解答填入答题纸的对应栏内。【说明】某系统在线讨论区采用ASP+Access开发,其主页如图4-1所示【问题2】(7分)该网站在主页上设置了分页显示,每页显示10条留言,以下是该网站页面分页显示部分代码,请阅读程序代码,并(9)~(15)的空缺代码补齐。<%Set rs = server.CreateObject(“adodb.recordset”)(9) = “select * from cont (10) by id desc ”rs.Open exec, conn, 1, 1If rs. (11) Then response.Write “ 暂无留言!Else rs.PageSize= (12) ’每页记录条数 iCount= rs.RecordCount’记录总数 iPageSize= rs.PageSize maxpage= rs.PageCount page= request(page) If Not IsNumeric(page) Or page=Then page = 1 Else lPage

    答案解析

  • 问答题

    第六题 阅读下列说明C++代码,填补代码中的空缺,解答填入答题纸的对应栏内。【说明 】以下C++代码实现一个超市简单销售系统中的部分功能,顾客选择图书等物品(Item)加入购物车(ShoppingCart),到收银台(Cashier)对每个购物车中的物品统计其价格进行结账,设计如图6-1所示类图。using namespace std;class Book;class Visitor {public: virtual void visit(Book* book)=0; //其它物品的visit方法};class Item {public:virtual void accept(Visitor* visitor)=0; virtual double getPrice()=0;};class Book (1){private: double price;public: Book (double price){ //访问本元素 (2); } void accept(Visi

    答案解析

热门题库