【发布时间】:2015-08-22 18:32:13
【问题描述】:
我教授的家庭作业代码如下。这是开箱即用的,我没有修改我教授的代码。该程序还有更多内容,但这是发生错误的地方。问题行以粗体显示。
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 包含行。
关于如何解决这个问题的想法,有人吗?它曾经给我所有位置的相同错误。
【问题讨论】:
-
您是否加入了
algorithm? -
非常感谢。你不知道我在这个任务上工作了多久。老师的密码开箱即用。如何将您标记为已回答的评论?
-
我重新写了一个答案的评论,如果答案解决了你的问题,你可以点击答案旁边的勾号。如果您的问题仍然得到解答,您可以编辑您的问题以获得更多/更好的答案。
标签: c++ c++11 netbeans std codeblocks