map主键是cstring类型的结构体, 怎么重载<
struct Student
{
CString name;
CString no;
}
map<Student, int> mapStudent;
该怎么重载结构体的<,求大神指教
[解决办法]
重载小于符号就可以了。
- C/C++ code
struct Student{ string name; string no; bool operator <(const struct Student& other) const { if (name < other.name) { return true; } else if (name == other.name) { return no < other.no; } return false; }};