C++ “;与';操作员<'”;尝试插入到std::set时
我使用gcc 4.3.3尝试编译以下代码:C++ “;与';操作员<'”;尝试插入到std::set时,c++,stl,set,C++,Stl,Set,我使用gcc 4.3.3尝试编译以下代码: struct testStruct { int x; int y; bool operator<(testStruct &other) { return x < other.x; } testStruct(int x_, int y_) { x = x_; y = y_; } }; int main() { multiset<testStruct> setti;
struct testStruct {
int x;
int y;
bool operator<(testStruct &other) { return x < other.x; }
testStruct(int x_, int y_) {
x = x_;
y = y_;
}
};
int main() {
multiset<testStruct> setti;
setti.insert(testStruct(10,10));
return 0;
}
struct testStruct{
int x;
int-y;
布尔运算符该运算符必须为常量并采用常量引用:
bool operator<(const testStruct &other) const { return x < other.x; }
bool运算符