cpp implementation of Populating Next Right Pointers in Each Node