As said before, please use the <algorithm> header and its std::min and std::max functions.