They measure your bust-- that's from the widest part of your chest all the way around. Then they measure just below your breasts. The number in inches that they get for the second number is your band size (the number in bra sizes, like 29A or 36D-- 29 and 38 are examples of your band measurement).
What they then do is subtract your band size from your bust size. The difference is what determines your cup size (AA, A, B, C, D, DD, etc.) I'm not sure on the numbers exactly, but I know that cup sizes tend only to be an inch or two apart from each other, so (estimating here) if there's, for example, a six inch difference between your bust and your band size, then you're an A cup, but if there's a seven inch difference, you're a B cup, eight inch difference, C cup, and so on and so forth.
EDIT: Keep in mind that these are AMERICAN sizings that I'm using.
link that helps explain the conversions between measuring your bra size in centimeters and inches.