为什么for_each这样不能通过编译
#include <afx.h>
#include <iostream.h>
#include <list>
#include <algorithm>
using namespace std;
typedef list<int> int_List;
class A
{
void PrintInt(int n)
{
cout<<n<<endl;
}
void test()
{
int_List nList;
nList.push_back(1);
nList.push_back(2);
nList.push_back(3);
nList.push_back(4);
for_each(nList.begin(),nList.end(),PrintInt);
}
};
void main()
{
}
错误提示
error C2664: 'for_each' : cannot convert parameter 3 from 'void (int)' to 'void (__thiscall *)(int)'