1,649
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
template <typename elementType>
struct DisplayElement
{
int a;
DisplayElement(int _a):a(_a)
{
cout<<"constructor"<<_a<<":"<<a<<endl;
}
void operator () (const elementType& element) const
{
cout << a<<":"<<element << endl;
}
};
int main(int argc, char *argv[])
{
vector<int> vecIntegers;
vecIntegers.resize(10);
for_each ( vecIntegers.begin () // Start of range
, vecIntegers.end () // End of range
, DisplayElement <int>(123) ); // Unary function object
return 0;
}
constructor123:123
123:0
123:0
123:0
123:0
123:0
123:0
123:0
123:0
123:0
123:0
请按任意键继续. . .
为何我的VS2008上运行是一样的?
你何不断点单步一下呢?