Can I use ' == ' to compare two vectors. I tried it and seems to be working fine. But I don't know whether it will work in more complex situations

前端 未结 6 1194
予麋鹿
予麋鹿 2021-02-01 12:30

First example:

int main(){
    using namespace std;   
    vector v1{10, 20, 30, 40, 50};
    vector v2{10, 20, 30, 40, 50};

    if(v1==v2         


        
6条回答
  •  无人及你
    2021-02-01 13:05

    Yes, you can use operator== to compare two std::vectors. It will return true only if the vectors are the same size and all elements compare equal.

提交回复
热议问题