我教授作业的代码如下。这是直接拿来就用的,我没有修改过我的教授的代码。程序还有更多内容,但这就是错误发生的地方。问题行已加粗。
std::cout << "\nAll remaining courses with enrollments:\n";
allCourses = WSUCourse::getAllCourses();
std::for_each(
allCourses.begin(),
allCourses.end(),
WSUCoursePrinter());
我收到了以下错误信息。
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' failed
总之,这就像标题所说的一样。 "'For each' is not a member of std"
。我已经在编译器中启用了所有IDE的标准11支持。在代码块中,我将参数放在编译器设置中,在Netbeans中,我在编译器的项目属性下进行了更改,即使是校园网络上的Linux系统也无法运行它,出现相同的错误,并且我使用了标准11包含行。
有人对如何修复此问题有什么想法吗?以前它在所有位置都给我相同的错误。