The absolute magnitude of a star is defined to be the apparent magnitude it would have if it were at a distance of 10 parsecs (about 32.616 light years).
For comets and asteroids a different definition of absolute magnitude is used, because the above one would be of little use. In this case, the absolute magnitude is defined as the apparent magnitude that the object would have if it were one astronomical unit from both the Sun and the Earth and at a phase angle of zero degrees. This is a physical impossibility, but it is convenient for purposes of calculation.