I am just making some code for my program, but eventually I forgot to write a little symbol and got error, Please, help to understand what's wrong here.
The code I wanted to write -
int arr[3][2] = {with some values};
for(auto &i : arr) {
for(int j : i)
cout << j << " " ;
cout << endl;
}
The code I wrote accidentlly -
int arr[3][2] = {with some values};
for(auto i : arr) { // just forgot to write (&) and got error
for(int j : i)
cout << j << " " ;
cout << endl;
}
The thing I know - Reference ("&") operator make us able to change the values inside the loop itself.
But what is the error in second loop, I mean it can deep copy the array objects, one by one, and create separate objects and then iterate over them, though we will not be able to change array values itself.
Error I got - 'std::end' declared here 1244 | end(const valarray<_Tp>& __va)
Aucun commentaire:
Enregistrer un commentaire