What will be printed out as a result of the following code execution? (C++11)
#include <iostream>
#include <vector>
#include <cstddef>

int main()
{
    std::vector<bool> v = {true, false, true, false};
    std::vector<int> v2(v.begin(), v.end()); // 1
    v.flip(); // 2
    for (std::size_t i=0; i != v.size(); ++i)
        std::cout << (v[i] & v2[i]);
}
Explanation
During the initialization of the vector v2, a a type conversion is performed. The specialization of the template class vector with elements of type bool has a flip method, which assigns the opposite value for each element (false=>true, true=>false).

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести