d_book.h

来自「本软件利用VC++树结构」· C头文件 代码 · 共 76 行

H
76
字号
#ifndef VIDEO_CLASS
#define VIDEO_CLASS
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

class book
{
	public:
		book(const string& aauthor= "",const string& aname= "", 
			const string& aISBN= "",const string& apudate= "",int copies = 1):
			name(aname), ISBN(aISBN),author(aauthor),
			pudate(apudate),numCopies(copies){}
	
	   void updateCopies(int n)
		{
			numCopies += n;
		}

		int getCopies()
		{
			return numCopies;
		}
		void setCopies(int a)
		{
			numCopies+=a;
		}

		string&  getAuthor()
		{
			return author;
		}
		string& getName()
		{
			return name;
		}
		string& getISBN()
		{
			return ISBN;
		}
		string& getPudate()
		{
			return pudate;
		}
		friend bool operator== (const book& lhs, const book& rhs)
		{
			return lhs.author == rhs.author;
		}

		// compare video objects by comparing film titles
		friend bool operator< (const book& lhs, const book& rhs)
		{
			return lhs.author < rhs.author;
		}

		// output a video object
		friend ostream& operator<< (ostream& ostr, const book& obj)
		{   
			ostr <<left<<setw(15)<<obj.ISBN
				<<left<<setw(15)<<obj.name
				<<left<<setw(15)<<obj.author
				<<left<<setw(15)<<obj.pudate
				<<left<<setw(15)<<obj.numCopies;		
			return ostr;
		}
	private:
		string author;
		string name;
		string ISBN;
        string pudate;
		int numCopies;
};

#endif	// VIDEO_CLASS

⌨️ 快捷键说明

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