CPP-22-02 Exam Details

  • Exam Code
    :CPP-22-02
  • Exam Name
    :CPP - C++ Certified Professional Programmer
  • Certification
    :C++ Institute Certifications
  • Vendor
    :C++ Institute
  • Total Questions
    :228 Q&As
  • Last Updated
    :Jul 15, 2026

C++ Institute CPP-22-02 Online Questions & Answers

  • Question 191:

    What happens when you attempt to compile and run the following code?

    #include

    #include

    #include

    #include

    using namespace std;

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) { out<

    struct Add : public binary_function {

    int operator() (const int and a, const int and b) const {

    return a+b;

    }

    };

    int main() {

    int t[]={1,2,3,4,5,6,7,8,9,10};

    deque d1(t, t+10);

    deque d2(10);

    transform(d1.begin(), d1.end(), d2.begin(), bind2nd(Add(), 1));

    for_each(d2.rbegin(), d2.rend(), Out(cout));cout<

    return 0;

    }

    Program outputs:

    A. 1 2 3 4 5 6 7 8 9 10
    B. 2 3 4 5 6 7 8 9 10 11
    C. 10 9 8 7 6 5 4 3 2 1
    D. 11 10 9 8 7 6 5 4 3 2
    E. compilation error

  • Question 192:

    What will happen when you attempt to compile and run the code below, assuming that file test.out do not exist before the program execution?

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) {out<

    int main (){

    int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

    fstream f("test.out");

    list l(t, t+10);

    for_each(l.begin(), l.end(), Out(f));

    f.close();

    return 0;

    }

    A. file test.out will be created and opened for writing
    B. file test.out will be created and opened for reading
    C. no file will be created nor opened
    D. file test.out will contain sequence 1 2 3 4 5 6 7 8 9 10
    E. compilation error

  • Question 193:

    What happens when you attempt to compile and run the following code?

    #include

    #include

    #include

    using namespace std;

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) { out<

    struct Add {

    int operator()(int and a, int and b) {

    return a+b;

    }

    };

    int main() {

    int t[]={1,2,3,4,5,6,7,8,9,10};

    vector v1(t, t+10);

    vector v2(10);

    transform(v1.begin(), v1.end(), v2.begin(), bind1st(Add(),1));

    for_each(v2.rbegin(), v2.rend(), Out(cout));cout<

    return 0;

    }

    Program outputs:

    A. 1 2 3 4 5 6 7 8 9 10
    B. 2 3 4 5 6 7 8 9 10 11
    C. 10 9 8 7 6 5 4 3 2 1
    D. 11 10 9 8 7 6 5 4 3 2
    E. compilation error

  • Question 194:

    What happens when you attempt to compile and run the following code?

    #include

    #include

    #include

    using namespace std;

    int main(){

    int t[] ={ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };

    listv(t, t+10);

    set s1(v.begin(),v.end());

    if (s1.count(3) == 2) {

    s1.erase(3);

    }

    for(set::iterator i=s1.begin();i!= s1.end(); i++) {

    cout<<*i<<" ";

    }

    return 0;

    }

    A. program outputs: 1 2 3 4 5
    B. program outputs: 1 2 4 5
    C. program outputs: 1 1 2 2 3 4 4 5 5
    D. program outputs: 1 1 2 3 3 4 4 5 5
    E. compilation error

  • Question 195:

    What happens when you attempt to compile and run the following code?

    #include

    #include

    #include

    #include

    using namespace std;

    class B { int val;

    public:

    B(int v=0):val(v){}

    int getV() const {return val;}

    B operator ?(const B andb )const { return B(val ? b.val);}}; ostream and operator <<(ostream and out, const B and v) { out<

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) { out<

    int main() {

    B t1[]={1,2,3,4,5,6,7,8,9,10};

    B t2[]={1,2,3,4,5,6,7,8,9,10};

    vector v1(t1, t1+10);

    vector v2(t2, t2+10);

    vector v3(10);

    transform(v1.begin(), v1.end(), v2.rbegin(), v3.begin(), minus());

    for_each(v3.rbegin(), v3.rend(), Out(cout));cout<

    return 0;

    }

    Program outputs:

    A. 9 7 5 3 1 ?1 ?3 ?5 ?7 ?9
    B. ?1 ?3 ?5 ?7 ?9 9 7 5 3 1
    C. 1 3 5 7 9 ?1 ?3 ?5 ?7 ?9
    D. 1 3 5 7 9 ?1 ?3 ?5 ?7 ?9
    E. ?9 ?7 ?5 ?3 ?1 1 3 5 7 9

  • Question 196:

    What happens when you attempt to compile and run the following code?

    #include

    #include

    #include

    #include

    using namespace std;

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) { out<

    int main() {

    string t[]={"aaa","Aaa", "aAa","aaA","bbb","Bbb", "bBb", "bbB"};

    vector v1(t, t+8);

    sort(v1.begin(), v1.end());

    for_each(v1.begin(), v1.end(), Out(cout));cout<

    return 0;

    }

    Program outputs:

    A. Aaa Bbb aAa aaA aaa bBb bbB bbb
    B. Aaa aAa Bbb aaA aaa bBb bbB bbb
    C. bBb bbB bbb Aaa aAa Bbb aaA aaa
    D. Aaa aAa bBb bbB bbb Bbb aaA aaa
    E. compilation error

  • Question 197:

    What happens when you attempt to compile and run the following code?

    #include

    #include

    #include

    #include

    using namespace std;

    bool identical(int a, int b) {

    return b == 2*a?true:false;

    }

    int main() {

    int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};

    int u[] = {2,4,6,4,6,10,2,4,14,6,4,2,20,8,8,5};

    vector v1(t, t + 15);

    deque d1(u, u + 15);

    pair::iterator, vector::iterator > result;

    result = mismatch(d1.begin(), d1.end(), v1.begin(), identical); //Line I

    if (result.first == d1.end() andand result.second == v1.end()) {//Line II

    cout<<"Identical\n";

    } else {

    cout<<"Not identical\n";

    }

    return 0;

    }

    Program outputs:

    A. Identical
    B. Not identical
    C. compilation error at line marked I
    D. compilation error at line marked II

  • Question 198:

    What happens when you attempt to compile and run the following code?

    #include

    #include

    #include

    using namespace std;

    templateclass B { T val;

    public:

    B(T v):val(v){}

    T getV() const {return val;} bool operator < (const B and v) const { return val

    templateostream and operator <<(ostream and out, const B and v) { out<

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) { out<

    bool Less(const B anda, const B andb) { return int(a.getV())

    int main() {

    float t[]={2.28, 1.66, 1.32, 3.94, 3.64, 2.3, 2.98, 1.96, 2.62, 1.13};

    vector > v1; v1.assign(t, t+10);

    stable_sort(v1.begin(), v1.end(), Less);

    for_each(v1.begin(), v1.end(), Out >(cout));cout<

    return 0;

    }

    Program outputs:

    A. 1.66 1.32 1.96 1.13 2.28 2.3 2.98 2.62 3.94 3.64
    B. 1.13 1.32 1.66 1.96 2.28 2.3 2.62 2.98 3.64 3.94
    C. compilation error
    D. 3.94 3.64 2.98 2.62 2.3 2.28 1.96 1.66 1.32 1.13
    E. the exact output is impossible to determine

  • Question 199:

    What happens when you attempt to compile and run the following code?

    #include

    #include

    #include

    #include

    using namespace std;

    class B { int val;

    public:

    B(int v=0):val(v){}

    int getV() const {return val;}

    operator int () const { return val;} };

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) { out<

    int main() {

    B t[]={3,2,4,1,5,6,10,8,7,9};

    vector v1(t, t+10);

    for_each(v1.begin(), v1.end(), bind1st(plus(), 1));

    for_each(v1.rbegin(), v1.rend(), Out(cout));cout<

    return 0;

    }

    Program outputs:

    A. 3 2 4 1 5 6 10 8 7 9
    B. 4 3 5 2 6 7 11 9 8 10
    C. 9 7 8 10 6 5 1 4 2 3
    D. 10 8 9 11 7 6 2 5 3 4
    E. compilation error

  • Question 200:

    What happens when you attempt to compile and run the following code? Choose all that apply.

    #include

    #include

    #include

    using namespace std;

    class A

    {

    int a;

    public:

    A(int a) {this?>a = a; c++;}

    A(const A and a) {this?>a = a.a; c++;}

    ~A() { c??;}

    static int c;

    };

    int A::c(0);

    int main ()

    {

    A* t[] = {new A(1), new A(2), new A(3),new A(4), new A(5)};

    vectorv1(t, t+10);

    dequed1(v1.begin(), v1.end());

    d1.clear();

    v1.clear();

    cout<

    return 0;

    }

    A. there are 15 A objects created,
    B. there are 5 A objects created,
    C. for all object A the destructor is called
    D. program will display 5

Tips on How to Prepare for the Exams

Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPP-22-02 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.