In the previous examples, the melody consists entirely of notes from the major scale. However, many melodies use notes from outside the major scale, particularly in styles such as Rock, Funk, Blues and Jazz. These "outside notes" are called accidentals.
An accidental is a temporary alteration to a note or notes from a particular key. These accidentals often come from the chromatic scale starting on the same note as the major scale of the key the music is written in. Therefore, if you have a piece of music in the key of C which contains notes which are not in the C major scale, you can relate these notes to the C chromatic scale.