d_prod.h

来自「这是数据结构和算法的国外经典书籍.清华大学出版社出版的<数据结构C++语言」· C头文件 代码 · 共 37 行

H
37
字号
#ifndef PRODUCT_CLASS
#define PRODUCT_CLASS

#include <string>

using namespace std;

class product
{
	public:
		product(const string& cmpny = "", const string& nm = "" ):
					company(cmpny), name(nm)
		{}

		// access the value of the product company
		string getCompany() const
		{ return company; }

		// access the value of the product name
		string getName() const
		{ return name; }

		// determine order of objects based on value of company
		friend bool operator< (const product& lhs, const product& rhs)
		{ return lhs.company < rhs.company; }

		// check for objects with the same company
		friend bool operator== (const product& lhs, const product& rhs)
		{ return lhs.company == rhs.company; }

	 private:
		string company;
		string name;
};

#endif	// PRODUCT_CLASS

⌨️ 快捷键说明

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