cpp implementation of Rotate List