一、问题及代码
/*
* 文件名称:Ex5-1.cpp
- * 作 者:聂雪云
- * 完成日期:2017 年 5 月 7日
- * 版 本 号:cb v1.25.0
- * 对任务及求解方法的描述部分:
- * 输入描述:无
- * 问题描述:设计书类
- * 程序输出:略
- * 问题分析:略
- * 算法设计:略
- #include<iostream>
#include<string>
using namespace std;
class Book
{
public:
void setbook(string ,string ,string ,double ,int ,int );
void borrow();
void restore();
void print();
void set_No();
void get_No();
void numb();
private:
string name;
string writer;
string publicer;
double price;
int number;
int No;
};
void Book::setbook(string _name,string _writer,string _publicer,double _price, int _number,int _No)
{
name=_name;
writer=_writer;
publicer=_publicer;
price=_price;
number=_number;
No=_No;
}
void Book::borrow()
{
number--;
}
void Book::restore()
{
number++;
}
void Book::print()
{
cout<<"书名: "<<name<<endl;
cout<<"作者: "<<writer<<endl;
cout<<"出版社: "<<publicer<<endl;
cout<<"价格: "<<price<<endl;
cout<<"数量: "<<number<<endl;
cout<<"书号: "<<No<<endl;
}
int main()
{
Book NO;
NO.setbook("honggaoliang","moyan","beijingchubanshe",25,10,1);
NO.print();
NO.borrow();
return 0;
}二、运行结果
三、心得体会
知识点没掌握,浪费好多时间,要认真学习啊
四、知识点总结
类与对象