加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
book.h 953 Bytes
一键复制 编辑 原始数据 按行查看 历史
#ifndef _BOOK_H_
#define _BOOK_H_
#include<fstream>
#include<string>
#include<ctime>
namespace lib{
class Book{
public:
static bool time_cmp(const Book&,const Book&)noexcept;
Book(const std::string &id,const std::string &name):m_id(id),m_name(name),m_time(time(nullptr)){}
Book(const std::string &id,std::string &&name):m_id(id),m_name(name),m_time(time(nullptr)){}
Book(std::string &&id,const std::string &name):m_id(id),m_name(name),m_time(time(nullptr)){}
Book(std::string &&id,std::string &&name)noexcept:m_id(id),m_name(name),m_time(time(nullptr)){}
explicit Book(std::ifstream&);
bool operator<(const Book &other)const noexcept{
return m_id<other.m_id;
}
std::string show()const{
return "ID:"+m_id+"\tBorrower:"+m_name+"\tTime:"+ctime(&m_time);
}
std::string save()const{
return m_id+"\n"+m_name+"\n"+std::to_string(m_time);
}
private:
time_t m_time;
std::string m_id,m_name;
};
}
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化