小编use*_*549的帖子

'for each'不是std的成员.已启用C++ 11支持

我教授的家庭作业的代码如下.这是开箱即用的,我没有修改我教授的代码.程序还有更多内容,但这是错误发生的地方.问题行以粗体显示.

std::cout << "\nAll remaining courses with enrollments:\n";
allCourses = WSUCourse::getAllCourses();
std::for_each(
  allCourses.begin(),
  allCourses.end(),
  WSUCoursePrinter());
Run Code Online (Sandbox Code Playgroud)

我收到以下错误.

g++    -c -g -std=c++11 -MMD -MP -MF "build/Debug/Cygwin_4.x-Windows/main.o.d" -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
main.cpp: In member function 'void WSUStudentPrinter::operator()(const WSUStudent*)':
main.cpp:26:20: error: 'to_string' is not a member of 'std'
       std::cout << std::to_string(studentPtr->getUniqueID()) <<
                    ^
main.cpp: In function 'void test()':
main.cpp:162:4: error: 'for_each' is not a member of 'std'
    std::for_each(
    ^
main.cpp:174:4: error: 'for_each' is not a member of 'std'
    std::for_each(
    ^
nbproject/Makefile-Debug.mk:84: recipe for target 'build/Debug/Cygwin_4.x-Windows/main.o' …
Run Code Online (Sandbox Code Playgroud)

c++ netbeans std codeblocks c++11

4
推荐指数
1
解决办法
5285
查看次数

标签 统计

c++ ×1

c++11 ×1

codeblocks ×1

netbeans ×1

std ×1