mercredi 25 février 2015

How to properly copy values from array to vector?

I have code that copies values from array to vector. But it does not work. In the last line I get


error: cannot bind 'std::basic_ostream' lvalue to 'std::basic_ostream&&' cout << "s: " << tv << endl; ^



int t[] = {1,2,3,4,5};
vector<int> tv;

for (int i=0;i<5;i++)
tv.push_back(i);

for (int v: tv)
cout << "s: " << tv << endl;

Aucun commentaire:

Enregistrer un commentaire