I would like to be able to do this instead to achieve the same result:
Writing a class to do what a function should do is a waste.
But, if you persist, I see no reason why you can't accomplish what you want. What have you tried? What problems did you have?