Is the following program legal? If so, what is the output?
#include <iostream>
#include <vector>
using namespace std;
int main( )
{
vector<int> v(10);
int i;
for (i = 0; i < v.size( ); i++)
v[i] = i;
vector<int> copy;
copy = v;
v[0] = 42;
for (i = 0; i < copy.size( ); i++)
cout << copy[i] << " ";
cout << endl;
return 0;
}
Sorry the answer is not available at the moment…
If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.
Spread the 'tradition of sharing'.