cpp implementation of reverse integer