Page 1 of 1

What will be the capacity of vector at the end in the following C++ code?

Posted: Wed Jul 13, 2022 7:53 pm
by answerhappygod
#include <iostream>
#include <vector>
 
using namespace std;
 
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
v.reserve(50);
cout<<v.capacity();
return 0;
}
a) 10
b) 8
c) 50
d) 60