C++ primer plus(第6版)中文版编程练习答案第10章
更新时间:2023-10-06 03:42:01 阅读量: 综合文库 文档下载
- c罗推荐度:
- 相关推荐
第10章
1、
//Customs.h
#include
class Customs {
private: string name; stringaccnum; double balance; public: Customs(const string &client, const string &num, double bal = 0.0); ~Customs(); void show()const; bool deposit(double cash); bool withdraw(double cash); };
//Customs.cpp
#include \
Customs::Customs(const string &client,const string &num, double bal) { accnum = num; name = client; balance = bal; }
Customs::~Customs() { }
bool Customs::deposit(double cash) { if (cash <= 0) { cout<< \ return false; } else { cout<< \ balance += cash; return true; } }
bool Customs::withdraw(double cash) { if (cash <= 0 || (balance - cash) < 0) { cout<< \ return false; } else { cout<< \ balance -= cash; return true; } }
void Customs::show()const { cout<< \ cout<< \ cout<< \}
//main.cpp
#include \
int main() { double input, output; charch;
}
Customs custom=Customs(\custom.show();
cout<< \ << \while (cin>>ch&&toupper(ch)!='Q') { while (cin.get() != '\\n') continue; if (!isalpha(ch)) { cout<< '\\a'; continue; } switch (ch) { case'A': case'a': cout<< \ cin>> input; if (!custom.deposit(input)) cout<< \ else cout<< \ break; case'P': case'p': cout<< \ cin>> output; if (!custom.withdraw(output)) cout<< \ else cout<< \ break; } custom.show(); cout<< \ << \}
cout<< \cin.get(); cin.get(); return 0;
2、
//person.h
#ifndef PERSON_H_ #define PERSON_H_
#include
using namespace std;
class Person {
private: staticconstint Person::LIMIT = 25; stringlname; charfname[LIMIT]; public: Person(){ lname = \ Person(const string &ln, const char *fn = \ void Show()const; voidFormalShow()const; };
#endif
//person.cpp
#include \
Person::Person(const string &ln, const char *fn) { lname = ln; strncpy_s(fname, fn, LIMIT); fname[LIMIT] = '\\0'; }
void Person::Show()const { cout< void Person::FormalShow()const { cout< //usePerson.cpp #include \ int main() { Person one; Person two(\ Person three(\ one.Show(); cout< 3、 //golf.h #ifndef GOLF_H_ #define GOLF_H_ #include using namespace std; class golf { private: staticconstint Len = 40;
正在阅读:
C++ primer plus(第6版)中文版编程练习答案第10章10-06
大学生心理知识竞赛题库(二)01-26
爆破工程复习11-03
C16079《证券业从业人员执业行为准则》 80分03-27
个人工作教学总结08-23
2013届中考英语语法考点知识复习507-18
粗盐中难溶性杂质的去除01-14
中国人民解放军各集团军编制战斗序列大全05-02
德育副校长述职报告09-26
- 人教新课标必修4 Unit2 Working the land名师导航
- 毕业生“校漂族”大行其道 - 0
- 江苏各市中考作文题出炉 - 0
- 暑期精品班 - 三角形 - 图文
- 情人节送什么礼物好??超强礼物已抵达
- 工程项目管理制度1
- 第四次业务学习 2016
- 会计要素与会计科目
- 欠发达地区小企业会计准则运用问题研究
- 一级锅炉水G4题库
- BBD双进双出筒式磨煤机安装使用说明书 SM-1
- 初一数学有理数教案
- 渝北区房地产评估市场调研报告
- iWebMall 数据字典
- 2018年小学入学教育工作计划
- 计量专业实务与案例分析 - 模拟题三 - 2013年版
- 启示录讲义
- 路基灰土改良(方案)
- 人行反洗钱岗位准入培训测试题集
- 2015电大《学前儿童发展心理学》期末试题及答案
- C++
- 中文版
- 练习
- 答案
- 编程
- primer
- plus
- 2017安全三类人员B类考试模拟试题与答案 - 图文
- SAT难度增添 专家:拿高分须多读英文原著
- 社会语言学调查报告
- 奥数题(刘媛媛第10-18道)
- 村居后备干部参考考试卷模拟试卷
- 大型火力发电厂汽机考试题库资料
- 广东省广州市重点高中2016届高考化学考前冲刺模拟试题三
- 基于PLC的四节传送带控制系统设计
- 中央电大本科社会心理学(本)试题1月
- 2013年教师新课改强化试题试卷及参考答案(32页)
- 2014 年考前冲刺题公司信贷
- 软件工程复习题及答案 - 图文
- 医学伦理学与卫生法学重点
- 2017年安全三类人员B类考试模拟试题及参考答案 - 图文
- 鹤煤组干(2011)18号-关于董正亮时奇巍杨敏等898名同志具备相应高中初级专业技术职务任职资格的通知 - 图文
- 发展心理学新进程第五讲(应科) - 图文
- 三类人员考试模拟试题
- 三类人员安全B证考试题库
- 《缔造完美教室》主题报告--朱永新 - 图文
- 山东省2012年专升本大学语文真题详解