Answered syntax error : missing ',' before ':' in VS2008

  • Thursday, September 20, 2012 7:19 AM
     
      Has Code

    syntax error : missing ',' before ':' in VS2008

    at

    for (auto shape : shapes)

    error C2039: 'str_Iter' : is not a member of 'std::vector<_Ty>'

    for (std::vector<Father*>::str_Iter = shapes.begin(); str_Iter != shapes.end(); str_Iter++ )

    成全佢

All Replies

  • Thursday, September 20, 2012 9:09 AM
    Moderator
     
     Answered Has Code

    VS 2008 doesn't support range based for syntax nor auto, you need VS2012 for that.

    The second line has an error in the str_Iter variable declaration, it should be like this:

    for (std::vector<Father*>::iterator str_Iter = shapes.begin(); str_Iter != shapes.end(); str_Iter++)