adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <vector>
    using namespace std;
    int main ()
    {
        vector<int> myvector;
        int * p;
        unsigned int i;
        p = myvector.get_allocator().allocate(5);
        for (i = 0; i < 5; i++) 
            myvector.get_allocator().construct(&p[i], i);
        for (i = 0; i < 5; i++)
            cout << ' ' << p[i];
        for (i = 0; i < 5; i++)
            myvector.get_allocator().destroy(&p[i]);
        myvector.get_allocator().deallocate(p, 5);
        return 0;
    }

a.

1 2 3 4 5

b.

0 1 2 3 4

c.

1 2 3 4

d.

5 4 3 2 1

Answer: (b).0 1 2 3 4

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?