Okay. So I'm currently reading a C++11 book, which told me to try out that thing:
int v[] = {1,2,3,4,5};
for (auto i : v)
{
std::cout<<i<<std::endl;
}
And yay, it works! But now, when I have:
#include <iostream>
void write(int* v)
{
for (auto i : v)
{
std::cout<<i<<std::endl;
}
}
int main(int argc, char** argv)
{
int v[] = {1,2,3,4,5};
write(v);
}
I get this:
main.cpp:6:19: error: 'begin' was not declared in this scope
for (auto i : v)
and main.cpp:6:19: error: 'end' was not declared in this scope
for (auto i : v)
+ 'suggested alternatives' (bunch of lines with mingw paths)
Am I doing something wrong, or there's no way to use this loop outside the function, where a collection was defined?