运算符重载

mac2026-01-06  8

struct Item{ int xi; int yi; //friend bool operator < (const Item & p1, const Item & p2) { // return p1.yi < p2.yi; //} //friend bool operator == (const Item & p1, const Item & p2) { // return p1.yi == p2.yi; //} bool operator < (const Item & p2) const { return this->yi < p2.yi; // 未考虑xi } bool operator == (const Item & p2) const { return this->yi == p2.yi; } }; map<Item, Item> inputList; inputList.insert(std::make_pair(o, o));

 

最新回复(0)