Which of these 2 methods is better and why?

Method 1:

void fun(int i) {
  //do stuff
}

...
for_each(a.begin(), a.end(), fun);

Method 2:

class functor {
public:
  void operator()(int i);
};

...
for_each(a.begin(), a.end(), functor());

Edit: Should have formulated it this way, in what situation is one of the above method preferable to the other?

Thanks a lot!

Edit
Report