Q:

What are the types of the following four objects

0

What are the types of the following four objects?

vector<int> v1;
const vector<int> v2;
auto it1 = v1.begin(), it2 = v2.begin();
auto it3 = v1.cbegin(), it4 = v2.cbegin();

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

    vector<int> v1;
    const vector<int> v2;
    //auto it1 = v1.begin(), it2 = v2.begin();
    // it1 and it2 have different type, thus need be seperated into two statements.
    auto it1 = v1.begin();
    // the type of `it1` is `vector<int>::iterator`
    auto it2 = v2.begin();
    // the type of `it2` is `vector<int>::const_iterator`
    auto it3 = v1.cbegin(), it4 = v2.cbegin();
    // the type of `it3` and `it4` is `vector<int>::const_iterator`

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now