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

📄 d_video.h

📁 数据结构c++语言描述stl版 威廉兄弟的好书,值得看,这是配书代码
💻 H
字号:
#ifndef VIDEO_CLASS
#define VIDEO_CLASS

#include <iostream>
#include <string>

using namespace std;

class video
{
	public:
		// constructor. initialize film title and numCopies
		video(const string& film = "", int copies = 1):
			filmTitle(film), numCopies(copies)
		{}

		// add n to the number of copies. note that if n < 0
		// the function decreases the number of copies
		void updateCopies(int n)
		{
			numCopies += n;
		}
		
		// return the number of copies of the film title
		int getCopies()
		{
			return numCopies;
		}
		
		// two video objects are "equal" if they have the same title
		friend bool operator== (const video& lhs, const video& rhs)
		{
			return lhs.filmTitle == rhs.filmTitle;
		}

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

		// output a video object
		friend ostream& operator<< (ostream& ostr, const video& obj)
		{ 
			ostr << obj.filmTitle << " (" << obj.numCopies << ")" ;
			return ostr;
		}
	private:
		// title of the film
		string filmTitle;
		// number of copies (>= 0)
		int numCopies;
};

#endif	// VIDEO_CLASS

⌨️ 快捷键说明

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