"for everyone" is not a member of std. C ++ 11 support is already included

The code for my homework for the teacher is as follows. This is right out of the box, I have not changed the code of my professor. The program has more, but an error occurs here. The problem line is in bold.

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

I get the following error.

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

To summarize, this is exactly the same as the name. "'For each' is not a member of std" I have already included standard 11 support in the entire IDE in which I compiled it. In blocks of code, I put the argument in the compiler options, in netbeans I changed it in the project properties on the compiler, even the Linux system on the school network won’t run it with the same error, and I used the standard inclusion line 11.

, , -? , .

+4
2

:

#include<algorithm>. , foreach std .

+9

++ 98, , ++ 11 :

std::cout << "\nAll remaining courses with enrollments:\n";
for (auto & course : WSUCourse::getAllCourses())
{
    //whatever WSUCoursePrinter does.
    course.print() ;
}

, .

+3

All Articles