Cosmetic dentistry is performed by a dentist that specializes in advanced cosmetic dentistry. While general dentistry deals with aspects involving oral health and function cosmetic dentistry focus on dental procedures that improve both the look and the function of a smile.
General dentistry is what helps maintain your oral health and solve dental pain and discomfort whereas cosmetic dentistry helps to fix things like cracked or chipped teeth, missing teeth, teeth whitening, and anything that improved the look of your smile.
They both have the same training. So a cosmetic dentist is also a general dentist and often vice versa.