I think you also need a CMidpoint::operator / which takes an int as a parameter, and you use that parameter in your division.