我的Github地址:https://github.com/lanbeilyj/Accerlerated-C-plus-plus

9-0. Compile, execute, and test the programs in this chapter.

Ans:见Github。

9-1. Reimplement the Student_info class so that it calculates the finalgrade when reading the student's record, and stores that grade in the object. Reimplement thegrade function to use this precomputed value.

Ans:见Github。

9-2. If we define the name function as a plain, nonconst member function, what other functions in our system must change and why?

Ans:我们只须要改动函数 compare()的參数类型就可以:将原先的bool compare(const Student_info& x,const Student_info& y)改为

bool compare(Student_info x,Student_info y)

Tips:const对象不能够调用const成员函数函数。

为什么又把 Student_info& 改成了Student_info x?

由于sort(students.begin(),students.end(),compare),函数中传递给compare是一个const对象,由于不能用一个const对象来初始化一个非const引用,故须要改动为传值形式。

9-3. Our grade function was written to throw an exception if a user tried to calculate a grade for aStudent_info object whose values had not yet been read. Users who care are expected to catch this exception. Write a program
that triggers the exception but does not catch it. Write a program that catches the exception.

Ans:见Github。

9-4. Rewrite your program from the previous exercise to use thevalid function, thereby avoiding the exception altogether.

Ans:见Github。

9-5. Write a class and associated functions to generate grades for students who take the course for pass/fail credit. Assume that only the midterm and final grades matter, and that a student passes with an average exam score greater than 60. The
report should list the students in alphabetical order, and indicate P or F as the grade.

Ans:见Github。

9-6. Rewrite the grading program for the pass/fail students so that the report shows all the students who passed, followed by all the students who failed.

Ans:见Github。

9-7. The read_hw function §4.1.3/57 solves a general problem (reading a sequence of values into avector) even though its name suggests that it should be part of the implementation ofStudent_info. Of course,
we could change its name—but suppose, instead, that you wanted to integrate it with the rest of theStudent_info code, in order to clarify that it was not intended for public access despite its apparent generality? How would you do so?

Ans:见Github。

Accelerated C++:通过演示样例进行编程实践——练习解答(第9章)的更多相关文章

  1. 最简单的视音频播放演示样例3:Direct3D播放YUV,RGB(通过Surface)

    ===================================================== 最简单的视音频播放演示样例系列文章列表: 最简单的视音频播放演示样例1:总述 最简单的视音频 ...

  2. 【UNIX网络编程(三)】TCP客户/server程序演示样例

    上一节给出了TCP网络编程的函数.这一节使用那些基本函数编写一个完毕的TCP客户/server程序演示样例. 该样例运行的过程例如以下: 1.客户从标准输入读入一行文本,并写给server. 2.se ...

  3. C编程规范, 演示样例代码。

    /*************************************************************** *Copyright (c) 2014,TianYuan *All r ...

  4. MVC模式编程演示样例-登录验证(静态)

    好,上篇博客分享了本人总结的JSP-Servlet-JavaBean三层架构编程模式的实现思想和基本流程,接下来给大家分享一个MVC编程模式的实现演示样例-登录验证的过程,这里我仍然用的是静态的验证u ...

  5. 构造Scala开发环境并创建ApiDemos演示样例项目

    从2011年開始写Android ApiDemos 以来.Android的版本号也更新了非常多,眼下的版本号已经是4.04. ApiDemos中的样例也添加了不少,有必要更新Android ApiDe ...

  6. android listview综合使用演示样例_结合数据库操作和listitem单击长按等事件处理

    本演示样例说明: 1.自己定义listview条目样式,自己定义listview显示列数的多少,灵活与数据库中字段绑定. 2.实现对DB的增删改查,而且操作后listview自己主动刷新. 3.响应用 ...

  7. 百度地图 Android SDK - 检索功能使用的简单演示样例

    百度地图 SDK 不仅为广大开发人员提供了炫酷的地图展示效果.丰富的覆盖物图层,更为广大开发人员提供了多种 LBS 检索的能力. 通过这些接口,开发人员能够轻松的訪问百度的 LBS 数据,丰富自己的移 ...

  8. [hadoop系列]Pig的安装和简单演示样例

    inkfish原创,请勿商业性质转载,转载请注明来源(http://blog.csdn.net/inkfish ).(来源:http://blog.csdn.net/inkfish) Pig是Yaho ...

  9. 最简单的视音频播放演示样例5:OpenGL播放RGB/YUV

    ===================================================== 最简单的视音频播放演示样例系列文章列表: 最简单的视音频播放演示样例1:总述 最简单的视音频 ...

随机推荐

  1. js插件---图片裁剪photoClip

    js插件---图片裁剪photoClip 一.总结 一句话总结:页面裁剪图片得到base64格式的图片数据,然后把这个数据通过ajax上传给服务器,服务器将base64图片数据解析成图片并且保存到服务 ...

  2. 开启Windows 7远程桌面功能的做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 本设置方法同样适用用Vista和Windows Server 2008. 1.依次点击"开始"菜单 ...

  3. asp.net 关于cookie的操作

    一.无子键或单级cookie 读写(1).写入: 第一种 HttpCookie cookie=new HttpCookie("User"); cookie.Value=" ...

  4. 【转】一篇关于32位Linux内核使用大内存的文章——Hugemem Kernel Explained  &nb

    红旗DC系列Linux操作系统(x86平台)中带有四类核心: UP (支持单内核) SMP (支持多内核) hugemem Icc* (用intel C编译器编译的核心) 其中hugemem核心往往引 ...

  5. 51nod 子序列的个数 (动规分析方法)

    这道题的分析方法我很需要学习学习. 一开始我想的是f[i][j]表示前i个数子序列长度为j的个数 然后发现新加入一个数的时候会和前面的重复,这个时候不知道该怎么处理这种重复. 其实我再继续往下想就可以 ...

  6. web——前后端通信

    前端向后台传输数据: 传输方法:post  get 区别: (1)get:用于从服务器获取数据,将参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看 ...

  7. 洛谷——P1518 两只塔姆沃斯牛 The Tamworth Two

    https://www.luogu.org/problem/show?pid=1518 题目背景 题目描述 两只牛逃跑到了森林里.农夫John开始用他的专家技术追捕这两头牛.你的任务是模拟他们的行为( ...

  8. jni中调用java方法获取当前apk的签名文件md5值

    相应的java方法: void getsign(Context context) throws Exception { PackageInfo localPackageInfo = context.g ...

  9. ACM-康托展开+预处理BFS之魔板——hdu1430

    魔板 Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submis ...

  10. IsoAlgo3d - IDF/PCF pipeline 3d viewer

    IsoAlgo3d - IDF/PCF pipeline 3d viewer eryar@163.com Key Words. IDF, PCF, IsoAlgo, 3D 当前国际主流管道设计软件都可 ...