"自动更改意义于c ++ 11"

Sla*_*lay 1 c++ iterator operators c++11

#include<iostream>
#include<string>
#include<iterator>
using namespace std;
int main()
{
    string a("hello world");
    for(auto it = a.begin(); it != a.end() && !isspace(*it); it++ )
    {
        *it = toupper(*it);
    }
    cout<<a;
}
Run Code Online (Sandbox Code Playgroud)

我得到了两个错误.一个是如上所述,"自动更改意味着在c ++ 11中",另一个是"!=运算符未定义".从来没有遇到过这个问题.

我只使用了自动运算符,因为本书建议.

我是初学者,大约2个月后回到学习.遇到困难.

pre*_*uin 8

编译时你的代码运行正常-std=c++11,你可以在这里查看.

您可以Setting->Compiler->Have g++ follow the C++11 ISO C++ language standard [-std=C++11]在CodeBlocks中添加选项.