Different types of digital camera use different sized sensors. The larger the sensor, the better the picture quality, though the cost increases too. This diagram shows the common sizes:
Apart from specialised studio cameras, the largest are in full-frame digital SLRs, the next largest are in the more common 'APS-C' format SLRs and Micro Four Thirds hybrid cameras, while the smallest are in compact cameras.
The physical size of a sensor is now more important for picture quality than its megapixel rating. With a small sensor, the image has to be enlarged by much more to produce a same-sized print etc. It's like the difference between small negatives and big negatives in the days of film.
There are also technical problems with small sensors that have high megapixel ratings. The tiny pixels on these sensors are nowhere near as sensitive to light and they produce much more random noise than the larger pixels on bigger sensors. This means the makers have to build in strong noise reduction processes, which gives photos a soft and hazy look.
In fact while the resolution of compact cameras has climbed steadily over the past few years, it's probably fair to say that the actual picture quality has stayed the same or even gone backwards.
The bigger the sensor, the better the picture quality, and the gain in quality is pretty much proportional to the sensor size. The table below shows that you don't need that many megapixels to produce good-quality prints, but that the enlargement factor with small sensors is many times higher. Enlargements of up to 30x are usually fine (indicated in green), but when you go beyond this, the definition starts to suffer. There is a limit to how much any lens can resolve, and how much you can blow up the image it produces.
So megapixels are no longer particularly relevant for compact cameras because they've already reached the point where more isn't making any difference, and in fact may be making things worse.
Because the sensors in digital SLRs are much larger, there is still something to be gained from higher megapixel counts, though even here there are signs that diminishing returns are setting in.