#include <cstdlib> #include <iostream> #include <string> using namespace std; int main() { string str("hello world!"); for (auto &c : str) c = toupper(c); cout << str; return 0; } This c++ code does not compile. Error msg: main.cpp:21: error: a function-definition is not allowed here before ':' token Question: Is there a for each loop in c++ (range for loop?)? what is wrong with the for each loop above?
Thanks in advance.