Exam Details

  • Exam Code
    :CPP
  • Exam Name
    :C++ Certified Professional Programmer
  • Certification
    :C++ Institute Certifications
  • Vendor
    :C++ Institute
  • Total Questions
    :228 Q&As
  • Last Updated
    :Jul 17, 2025

C++ Institute C++ Institute Certifications CPP Questions & Answers

  • Question 41:

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

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    int main()

    {

    deque mydeck;list mylist; vector myvector;

    queue first; queue second(mydeck);

    queue third(second); queue > fourth(mylist);

    fourth.push(10);fourth.push(11);fourth.push(12);

    queue > fifth(myvector);

    fifth.push(10);fifth.push(11);fifth.push(12); // Line I

    while(!fifth.empty())

    {

    cout<

    fifth.pop(); // Line III

    } while (!fourth.empty()) { cout << fourth.front() << " "; fourth.pop(); // Line IV } return 0; }

    A. program outputs: 10 11 12 10 11 12

    B. compilation error in line I

    C. compilation error in line II

    D. compilation error in line III

    E. compilation error in line IV

  • Question 42:

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

    #include

    #include

    using namespace std;

    class A

    {

    int a;

    public:

    A():a(0){} A(int a){ this?>a = a;}

    void setA(int a) {this?>a = a;}

    int getA() {return a;}

    };

    ostream andoperator<<(ostream and cout, A and a)

    {

    cout<< a.getA();

    return cout;

    }

    int main ()

    {

    vectorv(5, new A());

    v.push_back(new A(1));

    vector::iterator it;

    for(it = v.begin(); it != v.end(); it++)

    {

    cout<<*it<<" ";

    }

    cout<

    return 0;

    }

    A. program outputs 0 0 0 0 0 1

    B. program outputs 0 0 0 0 0 0

    C. compilation error

    D. program outputs 1 1 1 1 1 1

    E. none of these

  • Question 43:

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

    #include

    #include

    int main ()

    {

    std::vectorv1;

    for(int i = 0; i<10; i++) {v1.push_back(i); }

    std::vector v2(v1.begin()+2, v1.end()?2);

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

    for( ; it != v2.end(); it++) {std::cout<<*it++<<" "; }std::cout<

    return 0;

    }

    A. compilation error

    B. program outputs 0 1 2 3 4 5 6 7 8 9

    C. program outputs 2 3 4 5 6 7

    D. program outputs 2 4 6

  • Question 44:

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

    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"};

    map m;

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

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

    }

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

    m.erase(3);

    }

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

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

    }

    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. program outputs: one two three four five

  • Question 46:

    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

  • Question 47:

    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<

    template

    struct Add : public binary_function {

    A operator() (const A and a, const A 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 48:

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

    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() { B t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};

    B t1[]={B(1),B(2),B(3),B(4)};

    deque d1(t, t+10);

    set s1(t, t+10);

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

    cout<

    <

    return 0;

    }

    Program outputs:

    A. 1 1

    B. 1 0

    C. 0 1

    D. 0 0

    E. compilation error

  • Question 49:

    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 {

    int operator()(int a, int 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(ptr_fun (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 50:

    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;} };

    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 t[]={3,2,4,1,5,6,10,8,7,9};

    vector v1(t, t+10);

    transform(v1.begin(), v1.end(), v1.begin(), bind2nd(plus(), 1));

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

    }

    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

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 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.