C++第五次实验报告
来源:互联网 发布:怎样开淘宝网店教程 编辑:程序博客网 时间:2024/05/29 14:28
* 文件名称:
* 作 者:汪荣建
* 完成日期: 2017年 4月 24日
* 版 本 号:v1.0
* 对任务及求解方法的描述部分:
* 输入描述:
* 问题描述:
* 程序输出:
* 问题分析:
* 算法设计:
*/
一:问题代码
#include <iostream>
#include<cstring>
using namespace std;
class Book
{
public:
void setBook(string,string,string,double,int,int);
void borrow();
void restore();
void print ();
void set_NO(int);
void get_NO();
private:
string name;
string writer;
string publicer;
double price;
int number;
int NO;
};
void Book::setBook(string na,string w,string pu,double pr,int num,int n)
{
name=na;
writer=w;
publicer=pu;
price=pr;
number=num;
NO=n;
}
void Book::borrow()
{
number=number-1;
}
void Book::restore()
{
number=number+1;
}
void Book::print()
{
cout<<"价格:"<<price<<endl;
cout<<"数量:"<<number<<endl;
cout<<"书号:"<<NO<<endl;
}
void Book::set_NO(int n)
{
NO=n;
}
void Book::get_NO()
{
cout<<NO<<endl;
}
int main()
{
int n;
Book book;
book.setBook("wang wu","da lao","kai xin",45.5,23,78569);
book.print();
cout<<endl<<"借出一本书后:"<<endl;
book.borrow();
book.print();
cout<<endl<<"还回一本书后:"<<endl;
book.restore();
book.print();
cout<<"将书号改为:";
cin>>n;
book.set_NO(n);
cout<<endl<<"更改书号后:"<<endl;
book.print();
return 0;
}
二:结果:
三:心得体会
还不太懂,要多练习关于类的知识。
- 第五次C语言上机实验报告
- 第五次C程序设计实验报告
- 第五次C语言上机实验报告
- 第五次实验报告
- 第五次实验报告
- 第五次实验报告
- 第五次上机实验报告
- 第五次上机实验报告
- 第五次上机实验报告
- 第五次上机实验报告
- 第五次上机实验报告
- 第五次上机实验报告
- C++第五次实验报告
- C++第五次实验报告
- C程序设计课程第五次上机实验报告
- C++第五次实验--实验报告
- C++第五次实验-实验报告
- 第五次实验报告(1)
- webpack笔记
- 如何使用java反射机制测试私有方法
- GAN 论文大汇总
- 头指针 头结点 优点
- Android之调用其他程序
- C++第五次实验报告
- Java关键字transient和volatile小结
- springboot +nginx +freemarker 模板的简单集成
- 嵌入式linux驱动-网络设备驱动笔记
- R语言之决策树CART、C4.5算法
- android 应用在切换系统字体大小和语言时,应用崩溃问题
- stm32 JTag 错误
- BAT(批处理脚本)实现文件的安装和卸载(一)
- leetcode题解-561. Array Partition I && 62. Unique Paths && 63. Unique Paths II