【10.1】c++ primer plus 课后编程答案
来源:互联网 发布:飞行员是什么意思网络 编辑:程序博客网 时间:2024/09/21 06:37
C++ PRIMER PLUS 课后答案
使用IDE为window7系统下的VS2010
/*user.h*/#ifndef USERSH_H_#define USERSH_H_#include <string> class countr{private: std::stringname; std::stringcount_num_; double money_;public: countr(std::stringp,std::string q,double m); countr(); ~countr(){}; void show() const; void save(double money); void out(double money);}; #endif
//////////////////////////////////*userfucntion.cpp*/#include "usersh.h"#include <iostream>using std::cin;using std::cout;countr::countr(){ name="noname"; count_num_="noname"; money_=0;} countr::countr(std::string p="no name",std::stringq="no name",double m=0){ name=p; count_num_=q; money_=m;} void countr::out(double money){ char ch; if(money_<money) { cout<<"themoney in your count is not enough,youcan out maxnuim:" <<money_<<'\n'; cout<<"pleaseenter Y to out, Q to quit:"; while(cin>>ch&&ch!='Q') { if(ch=='Y') { money_=0; break; } else { cout<<"pleaseenter again!:"<<'\n'; cout<<"(Y to out, Q to quit)"; continue; } } } else money_-=money;}void countr::save(double money){ money_+=money;} void countr::show()const{ cout<<name<<'\n'; cout<<count_num_<<'\n'; cout<<money_<<'\n';}
///////////////////////////////*main*/#include <iostream>#include <Windows.h>#include "usersh.h"#include <string>#include <cctype> int main(){ countr* r=new countr("LXK","meat",100); r->show(); r->save(100.5); r->show(); r->out(100.5); r->show(); r->out(100.5); r->show(); delete r; system("pause"); return 0;}
阅读全文
0 0
- C++primer plus第六版课后编程题答案10.1
- C++primer plus第六版课后编程练习答案10.1
- 【10.1】c++ primer plus 课后编程答案
- C++PRIMER PLUS第六版课后编程答案 4.1-4.5
- C++PRIMER PLUS第六版课后编程答案 4.6-4.10
- C++PRIMER PLUS第六版课后编程答案 5.1-5.5
- C++PRIMER PLUS第六版课后编程答案 5.6-510
- C++primer plus第六版课后编程题答案 6.1
- C++primer plus第六版课后编程题答案 6.2
- C++primer plus第六版课后编程题答案 6.3
- C++primer plus第六版课后编程题答案 6.4
- C++primer plus第六版课后编程题答案 6.5
- C++primer plus第六版课后编程题答案 6.6
- C++primer plus第六版课后编程题答案 6.7
- C++primer plus第六版课后编程题答案 6.8
- C++primer plus第六版课后编程题答案 6.9
- C++primer plus第六版课后编程题答案7.1
- C++primer plus第六版课后编程题答案7.2
- 哪里可以写技术微博?
- 6月4号学习笔记~
- linux-mysql删除
- 有序广播
- mysql 5.5 版本编译安装
- 【10.1】c++ primer plus 课后编程答案
- 图像处理之特征提取:LBP特征简单梳理
- FILE结构体与文件描述符
- 定位的配合使用
- spring第一篇----XmlBeanFactory 小结
- 基于ARM的RPi3+raspbian-jessie-lite-2017-04-10上OpenCV3.2.0在python2.7.9上本地编译安装及调用命令汇总
- LeetCode-557. Reverse Words in a String III
- H5小白入门笔记(3)
- 案例---拦截有序广播