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 221:

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

    #include

    using namespace std;

    template

    class A {

    T_v;

    public:

    A() {}

    A(T v): _v(v){}

    friend ostream and operator<<(ostream and c, const A and v);

    };

    template

    ostream and operator<<(ostream and c, const A and v) {

    c<

    int main()

    {

    Aa(10);

    cout<

    return 0;

    }

    A. program will display:10
    B. program will not compile
    C. program will compile
    D. program will run without output

  • Question 222:

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

    #include

    using namespace std;

    int main() {

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

    string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"};

    multimap m;

    for (int i = 0; i < 10; i++) {

    m.push_back(pair(t[i], s[i]));

    }

    for (multimap::iterator i = m.begin(); i != m.end(); i++) {

    cout << i?>first << " ";

    }

    return 0;

    }

    A. program outputs: 1 2 3 4 5
    B. compilation error
    C. program outputs: 1 1 2 2 3 3 4 4 5 5
    D. program outputs: one two three four five
    E. program outputs: one one two two three three four four five five

  • Question 223:

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

    #include

    #include

    #include

    using namespace std;

    int main(){

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

    vectorv(myints, myints+10);

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

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

    s1.erase(s1.lower_bound(2),s1.upper_bound(7));

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

    cout<<*i<<" ";

    }

    return 0;

    }

    A. program outputs: 0 1 8 9
    B. program outputs: 2 3 4 5 6 7
    C. program outputs: 1 6 5 7
    D. program outputs: 3 4 9 8 0

  • Question 224:

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

    #include

    #include

    #include

    using namespace std;

    class B { int val;

    public:

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

    int getV() const {return val;} bool operator < (const B and v) const { return 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() {

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

    vector v1(t, t+10);

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

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

    return 0;

    }

    Program outputs:

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

  • Question 225:

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

    #include

    #include

    using namespace std;

    template

    class A {

    T_v;

    public:

    A() {}

    A(T v): _v(v){}

    T getV() { return _v; }

    void add(T and a) { _v+=a; }

    void add(string and a) {

    _v.insert(0, a);

    }

    };

    int main()

    {

    Aa("Hello");

    string s(" world!");

    a.add(s);

    cout << a.getV() <

    return 0;

    }

    A. program will display: Hello world!
    B. compilation error
    C. program will display: world!Hello
    D. program will run without any output

  • Question 226:

    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):val(v){} B(){}

    int getV() const {return val;} bool operator > (const B and v) const { return val>v.val;} };

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

    ostream and out;

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

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

    int main() {

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

    deque d1(t, t+10);

    sort(d1.begin(), d1.end(), greater());

    deque::iterator it = lower_bound(d1.begin(), d1.end(), 4,greater());

    for_each(it, d1.end(), Out(cout));cout<

    return 0;

    }

    Program outputs:

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

  • Question 227:

    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() {

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

    int 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 228:

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

    #include

    #include

    class A {

    public:

    virtual int f() { return 10; }

    virtual ~A(){}

    };

    class B: public A {

    int f() {return 11; }

    virtual ~B(){}

    };

    int main (){

    std::vectorv1;

    for(int i = 10; i>0; i??)

    {

    i%2>0?v1.push_back(new A()):v1.push_back(new B());

    }

    std::vector::iterator it = v1.begin();

    while(it != v1.end())

    {

    std::cout<f()<<" ";

    v1.pop_back();++it;

    }

    return 0;

    }

    A. destructor of class A will be called
    B. destructor of class B will be called
    C. code will not compile
    D. program outputs 10 11 10 11 10
    E. program outputs 10 11 10 11 10 11 10 11 10 11

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.