⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 book.cpp

📁 C++语言课程设计- 图书管理系统 我个人在大一时做的 不足之处还请赐教
💻 CPP
字号:
#include<iostream.h>
#include<string.h>
#include"book.h"


//*******************************
//		公有函数定义
//*******************************
void book::setbookname(char *s)			 //设置ISBN号
{
	strcpy(bookname,s);
}
void book::setisbn(char *s)			   	 //设置书名
{
	strcpy(isbn,s);
}
void book::setauthor(char *s)				 //设置作者
{
	strcpy(author,s);
}
void book::setpublish(char *s)			 //设置出版单位
{
	strcpy(publish,s);
}
void book::setdateadd(char *s)             //设置进书日期
{
	strcpy(dateadd,s);
}
void book::setwholesale(float w)           //设置批发价
{
	wholesale=w;
}
void book::setretail(float r)              //设置零售价
{
	retail=r;
}
void book::setvolumn(int v)               //设置库存量
{
	volumn=v;
}

char*	book::getbookname()            //获取书名
{
	return bookname;
}
char*	book::getisbn()                //获取ISBN号
{
	return isbn;
}
char*	book::getauthor()                    //获取作者名
{
	return author;
}
char*	book::getpublish()                   //获取出版社名
{
	return publish;
}
char*	book::getdateadd()                   //获取进书日期
{
	return dateadd;
}
float	book::getwholesale()                 //获取批发价
{
	return wholesale;
}
int		book::getvolumn()              //获取库存量
{
	return volumn;
}
float	book::getretail()               //获取批发价
{	
	return retail;
}

//*******************************
//		重载运算符 <<(友员)
//*******************************
ostream & operator <<(ostream &os,book &p)
{
	os<<endl<<"\t书   名 :"<<p.getbookname()<<endl
	  <<"\tISBN 号 :"<<p.getisbn()<<endl
	  <<"\t作   者 :"<<p.getauthor()<<endl
	  <<"\t出版社  :"<<p.getpublish()<<endl
	  <<"\t进书日期:"<<p.getdateadd()<<endl
	  <<"\t库存量  :"<<p.getvolumn()<<endl	  
	  <<"\t批发价  :"<<p.getwholesale()<<endl
	  <<"\t零售价  :"<<p.getretail()<<endl;
	return os;
}

//*******************************
//		重载运算符 >>(友员)
//*******************************
istream & operator >>(istream &ins,book & p)
{
	cout<<"请输入你要添加书的信息:"<<endl<<endl;
	cout<<"请输入书名:"<<endl;
	ins>>p.bookname;
	cout<<"请输入ISBN号:"<<endl;
	ins>>p.isbn;
	cout<<"请输入作者的名字:"<<endl;
	ins>>p.author;
	cout<<"请输入出版社名:"<<endl;
	ins>>p.publish;
	cout<<"请输入进书日期:<如2005-04-30>"<<endl;
	ins>>p.dateadd;
	cout<<"请输入库存量:"<<endl;
	ins>>p.volumn;
	cout<<"请输入批发价:"<<endl;
	ins>>p.wholesale;
	cout<<"请输入零售价:"<<endl;
	ins>>p.retail;
//	ins.ignore();
	return ins;
}
//*******************************
//		重载运算符 =(成员函数)
//*******************************

book & book::operator =(book & p)
{
	(*this).setbookname(p.getbookname());			 //设置ISBN号
	(*this).setisbn(p.getisbn());			   		 //设置书名
	(*this).setauthor(p.getauthor());				 //设置作者
	(*this).setpublish(p.getpublish());				 //设置出版单位
	(*this).setdateadd(p.getdateadd());             //设置进书日期
	(*this).setwholesale(p.getwholesale());         //设置批发价
	(*this).setretail(p.getretail());               //设置零售价
	(*this).setvolumn(p.getvolumn());               //设置库存量
	return *this;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -