我有一组类 Item :
std::set <Item> items;
class Item
{
private:
std::string name;
std::string serialNum;
int count;
double unitPrice;
public :
Item(std::string _name, std::string _serialNum, int _count, double _unitPrice);
Item(); // Ctor with no parameters , for compiling
~Item(); //Dtor
double totalPrice();
bool operator<(Item const & other)const;
bool operator>(Item& other);
bool operator==(Item& other);
void operator=(const Item& other);
void countUp();
void countDown();
void setup(std::string _name, std::string _serialNum, int _count, double _UnitPrice);
int getCount() const ;
std::string getName() const;
std::string getSerial() const ;
double getPrice() const ;
void printItem() const ;
};
我可以只在集合中搜索一个值吗?例如,按 item :: name 在集合中搜索。