vendredi 27 mars 2020

How to check the value of an element in c++? [closed]

I'm trying to check for the element of a vector in c++, I have the following:

vector<string> result;

result.push_back('zeroth');
result.push_back('first');
result.push_back('second');

if (result[0] == 'zeroth') {
    //do stuff
}

and it throws the error: no operator "==" matches these operands -- operand types are: std::string == int

any way I can fix this? Thanks...

Aucun commentaire:

Enregistrer un commentaire