// range-based for loop
#include <iostream>
#include <string>
usingnamespace std;
int main ()
{
string str {"Hello!"};
for (char c : str)
{
std::cout << "[" << c << "]";
}
std::cout << '\n';
}
Why does this code give me 2 errors, 1 saying "Error: Range-based loops are not allowed in C++98" and another saying "in C++98 'str' must be initialised by contrusctor, not by '{...}""
I have tried installing tdm-gcc and searching the web, no specific answers. What can I do to fix this?
Right click your project in the left pane -> build options -> compiler settings -> check the box "enable support for c++ 11 standard" or something similar