How can I use the following vector to read true/false from using a while or for loop.
With this implemtation of the loop I get an error for the oprator !=
no operator "!=" matches these operands
vector<bool> Verification;
Verification.push_back(true);
Verification.push_back(false);
Verification.push_back(true);
Verification.push_back(false);
Verification.push_back(true);
for (int it = Verification.begin(); it != Verification.end(); it++) {
if (it==true) cout<<"true";
else if (it == false) cout<<"false";
}
int it = Verification.begin()should be a compile error too.itasintbut trying to put aniteratorin it. Changeinttovector<bool>::iterator. Although, personally I prefer this style-for(size_t i = 0; i < vector_name.size(); i++)*it==trueis the same as*it, is the same as(*it == true) == true. Just use theboolvalue directly