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

前端 未结 8 965
说谎
说谎 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:22

    Because you did not write a comparison operator for your struct. The compiler does not generate it for you, so if you want comparison, you have to write it yourself.

提交回复
热议问题