cpp implementation of Swap Nodes in Pairs