“no match for 'operator<'” when trying to insert to a std::set

前端 未结 1 1900
太阳男子
太阳男子 2020-12-11 02:47

I\'m using gcc 4.3.3 to try to compile the following code:

struct testStruct {  
int x;  
int y;  
bool operator<(testStruct &other) { return x < o         


        
相关标签:
1条回答
  • 2020-12-11 03:22

    The operator must be const and take a const reference:

    bool operator<(const testStruct &other) const { return x < other.x; }  
    
    0 讨论(0)
提交回复
热议问题