So this should print 12345, but it actually prints 00000. I cannot figure out why.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <isotream>
#include <vector>
vector<int> suitors(10);
for(int i = 0; i < 5; ++i)
{
suitors.push_back(i + 1);
}
for(int i = 0; i < 5; ++i)
{
cout << suitors.at(i);
}
|
Last edited on
In line 4 you create a vector with 10 members, then you add five more.
Try changing line 11 to:
for (int i = 0; i < 15; i++)
and you'll see what I mean.
Remove (10) after suitors declaration.
Ahhhh gothca, that makes sense. Thanks!!