简易书店信息管理系统 C++ STL 链表

 头文件与声明

#include<iostream>
#include<string>
#include<list>
#include<sstream>
#include<fstream>
#include<iomanip>
#define MAX_BOOK 100
using namespace std;
template<class T>
T stringToNum(const string&str);

 定义一个书类并创建一个图书链表存放书目信息

class Book
{
public:
	string bookISBN;//编号
	string bookname;//书名
	int price;//价格
	int count;//数量	
	Book()
	{
		bookISBN = "0";
		bookname = "0";
		price = 0;
		count = 0;
	}
	Book(string ISBN, string name, int money, int num) :
		bookISBN(ISBN), bookname(name), price(money), count(num){}
	bool operator<(Book b) { return this->bookISBN<b.bookISBN; }//为了排序
	bool operator>(Book b) { return this->bookISBN>b.bookISBN; }

	void print()
	{//显示图书信息
		cout << bookISBN << setw(15) << bookname << setw(5) << price << setw(5) << count << endl;
	}
};
list<Book>lst;//图书链表,用于存放图书信息

 各个操作函数

void print(list<Book>lst, string name)
{//输入链表中所有书籍
	list<Book>::iterator it;
	cout << name << ":" << endl;
	cout << "编号" << setw(15) << "书名" << setw(11) << "价格" << setw(5) << "数量" << endl;
	for (it = lst.begin(); it != lst.end(); it++)
		it->print();
	cout << endl;
}
void screenA()//显示屏幕操作A
{
	cout << "****************************************" << endl;
	cout << "               1--------------查询" << endl;
	cout << "               2--------------排序" << endl;
	cout << "               3--------------插入" << endl;
	cout << "               4--------------删除" << endl;
	cout << "               5--------------显示" << endl;
	cout << "     
  • 4
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值