Since you're using list-initialization, why not all the other nice features of C++11?
Code:
vector<int> toReturn(){ // Using void to denote an empty parameter list is from C and has always been unusual for C++.
return {2, 4, 6, 8, 10};
}
int main(){ // If you don't use the command line arguments, why not use the parameter-less version of main?
auto v = toReturn(); // Don't really need to spell out the type here. You could though, if it's not obvious that toReturn gives you a vector<int>.
// (In this little example, it isn't, since toReturn isn't meaningful. But then, it's just a small example.)
for(auto iter = v.begin(); iter != v.end(); ++iter){ // This is where auto really shines. Do you really want to type vector<int>::iterator?
cout << *iter << " ";
}
// Or just write this:
for(auto i : v) { // Range-based for loop FTW!
cout << i << " ";
}
// Or since the rbfl keeps temporaries alive:
for(auto i : toReturn()) {
cout << i << " ";
}
cout << endl;
}