このコードを考えてみましょう:
for( std::vector<std::string>::iterator it = myVec.begin(), int i = 3; it < myVec.end(); it++, i++ )
{
// some operations with the vector
}
MSVC 2010で、これをforループでコンパイルするとエラーが発生することに非常に驚きました。MSVSでコンマ演算子の使用は禁止されていますか?
エラーは次のとおりです。
error C2062: type 'int' unexpected
error C2143: syntax error: missing ';' before ')'
「inti」定義をループから外そうとすると、次のようになります。
error C2440: 'initializing': cannot convert from 'int' to 'std::vector'