自定义for_each()行为,该怎么解决

自定义for_each()行为
目的:手动输入一个字符串,将其中非 "( ", ") "的字符均删除.利用String类.

如何利用for_each()来实现这个问题呢?

------解决方案--------------------
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
int main(int,char*[])
{
string str;
cin> > str;
str.erase(remove_if( str.begin() , str.end() ,bind2nd(not_equal_to <char> (), ', ') )
,str.end()
);
cout < <str < <endl;
return 0;
}