Other's have commented on how badly you've described your issues, and thrown complex template-based code at you that you probably don't understand. I strongly suggest that you read up on it; templates are powerful, useful, and a great programming technique. The downside is that you have to learn them first.
Here's a non-template oriented solution:
bool class3::filter(string word)
{
//You aren't mutating word, so don't waste your time
//(or memory) by copying it. In fact, I'd (strongly)
//recommend you utilize a constant pass by reference,
//because by default that's what you're already doing,
//so you were taking a copy of a copy. Waste of memory!
//Just init a count variable.
int count=0;
//Set up your for loop...
for(int i=0; i<word.size(); i++)
{
if(!isalnum(word[i]))
{
//If a character doesn't match, increment your counter
count++;
//If you want to, you can return false here if count>1 to improve efficiency -- depends on your end goal.
}
}
//If you want exactly one non-alphanumeric, then return this.
return count==1;
//Or if it's a maximum of one non-alphanumeric, then...
return count<=1;
//Or you could generalize by returning a count of non alphanumerics -- remember to change the return type!
return count;
}