私はC++にまったく慣れておらず、現在C++Primerの本をフォローしています。
文字列に関する小さな例を書きました。コードは次のとおりです。
#include <iostream>
#include <string>
#include <cctype>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main() {
string s("Hello World");
for (auto &c : s)
c = toupper(c);
cout << s << endl;
return 0;
}
LinuxでGCCバージョン4.4.6を使用していて、次のコードを使用してこのコードをコンパイルしようとしました。
g++ test_strings.c -std=c++0x
しかし、次のエラーが発生しました。
test_strings.c: In function 'int main()':
test_strings.c:14: error: expected initializer before ':' token
test_strings.c:19: error: expected primary-expression before 'return'
test_strings.c:19: error: expected ')' before 'return'
教科書からプログラムをコピーしたので、つづりが間違っていたのですが、チェックしてWebで検索し、gccを更新しようとすると、エラーが表示されます。よろしくお願いします。