It's a bit pointless having a function that just takes one line of code. Better just to use those single lines of code instead of calling the function; it looks here as if you're trying to rewrite C in some other language, which doesn't work. A function should do something useful, not just redefine an operator. Also the parameter names should be descriptive. n and d mean nothing. Do you mean numerator and denominator?