Start with the hexagonal A-B-A-B structure. It is hexagonal because, choosing one atom in a layer, it is surrounded by 6 equivalent atoms. So, you have a 6-fold symmetry axis, hence the 'hex-'. The fact that it is close-packed can be gotten at mathematically (or at least shown that it is closer-packed than other crystal structures).
Cubic close packing is, at least in most materials science and metallurgy circles, much more commonly called face centered cubic. The 'standard' unit cell is a cube of atoms with additional atoms at the center of each face. It is somewhat harder to visualize how this is related to close-packed planes, although there are many pictures available on-line (one, chosen somewhat randomly, is from Florida State). The point is that the stacking direction of the close-packed planes are along the 111 body diagonal of the cube.
Rotate the cube so that it is standing on one point with the opposite point on the body diagonal pointing up. Your close packed planes are:
(1) the bottom point, (2) the top point, (3) the three corner atoms closest to the bottom point as well as the face atoms closest to the bottom atom, (4) the three corner atoms closest to the top atom as well as the face atoms closest to the top atom. It may take some squinting...