C++实现一个简单图书借阅流程

该博客详细介绍了如何使用C++构建一个简单的图书借阅流程,包括myDate类、book类、student类和图书借阅记录record类的设计。作者指出record类的设计可能需要优化,考虑增加继承结构或直接包含bookid和studentid。
摘要由CSDN通过智能技术生成

总共实现了myDate类,book类,student类,图书借阅记录record类

//
#include <iostream>
#include <string>
#include <vector>
#include <list>

#include <ctime>
#include <cstdio>
using namespace std;

//主要就基于C库封装了一个获取时间戳的数据成员和相关方法
class myDate
{
        time_t _time;
public:
        myDate()
        {
                time (&this->_time);
                cout<<"get time sucessful"<<endl;
        }
        friend ostream& operator<<(ostream &out,myDate &d);
};
ostream& operator <<(ostream &out,myDate &d)
{
        out<<ctime(&(d._time));
        return out;
}

//book类主要封装一个图书信息(书名和数量)
class book
{
        //string bookid;
        string bookname;
        int    bookcount;
public:
        explicit book(string bname,int bcount):
            bookname(bname),bookcount(bcount)
        {

        }
        int  insertBook()
        {
            if(bookcount < 0)
                return -1;
            bookcount += 1;
            return 0;

        }
        int  removeBook()
        {
            if(bookcount <= 0)
                return -1;
            bookcount -= 1;
            return 0;
        }
        string& getname()
        {
            return bookname;
        }
        void print()
        {
            cout<<"bname:"<<bookname<<",count:"<<bookcount<<endl;
        }
};

//record类封装一条借阅记录<who,do,bookname>
class recordPer
{
    bool   f ;//true brrow    -- false return
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值