Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
#include
3.
using namespace std;
4.
int main ()
5.
{
6.
vector myvector;
7.
int * p;
8.
unsigned int i;
9.
p = myvector.get_allocator().allocate(5);
10.
for (i = 0; i < 5; i++)
11.
myvector.get_allocator().construct(&p[i], i);
12.
for (i = 0; i < 5; i++)
13.
cout
Options:
A .  1 2 3 4 5
B .  0 1 2 3 4
C .  1 2 3 4
D .  5 4 3 2 1
Answer: Option B

In this program, We allocated the values to the vector by using get allocater and then we are destroying it.
Output:
$ g++ seq3.cpp
$ a.out
0 1 2 3 4



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers