Hmmm. You may want to look int using a functor:

http://en.wikipedia.org/wiki/Function_object