Quick A: std::initalizer_list
. And did you know you can even do for(auto i: {1,2,3,4,5})
?
What type does auto use for containers?
I can achieve identical output by using different containers in C++. For example . .
std::array<int, 5> v = {1,2,3,4,5}; for(auto i : v) std::cout << i << ", ";or
std::vector<int> v = {1,2,3,4,5};or
int v[] = {1,2,3,4,5};etc.
So what container does auto use here?
auto v = {1,2,3,4,5}; for(auto i : v) std::cout << i << ", ";
Add a Comment
Comments are closed.