No == operator found while comparing structs in C++

前端 未结 8 971
说谎
说谎 2020-12-02 09:21

Comparing two instances of the following struct, I receive an error:

struct MyStruct1 {
    MyStruct1(const MyStruct2 &_my_struct_2, const int _an_int =          


        
8条回答
  •  情歌与酒
    2020-12-02 10:09

    Out of the box, the == operator only works for primitives. To get your code to work, you need to overload the == operator for your struct.

提交回复
热议问题