Hello I am on page 1286 of C++ primer. I am at the solutions part. here is an example in the book:
std::array<int, 10> a1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::array<int, 10> a2 = {0}; // elements all have value 0 a1 = a2; // replace elements in a1 a2 = {0}; // error: cannot assign to an array from a braced list
-
However we can assign to an
std::array
from a braced list soa2
is assigned0
to the first element and all the remaining elements are value-init to0
too. -
So is this a mistake in the book or just because of some change in the new Standard? Thank you!
Aucun commentaire:
Enregistrer un commentaire