Yes, separate shelves are best, but if you have to stack them, better by far to have the amp on top of the CD player as you suggest.
Perhaps use something like
this under the amp feet to increase the space between the two and allow more cooling air to circulate, not to mention keeping any interference from the amp transformer further from the player.