Aren't the different parts of it having a different pitch? Can't this be used to play a melody?
A drum is usually considered a non-pitched instrument because it produces a weak fundamental frequency, produces inharmonic overtones, and the pitches it does produce are unrelated to the rest of the ensemble. Certain drums can take on more pitch-like qualities by modifying some of these parameters.
A plucked string, for example, has a very strong fundamental frequency which is perceived as the loudest, which is the note you hear when plucking the string. It also produces harmonic overtones which are integer multiples of the fundamental frequency, which are related to the pitch of the note in a very simple manner. The plucked string's fundamental frequency must also somehow match the rest of the ensemble, or it will sound out of place.
A drum, on the other hand, does not produce a very strong fundamental frequency, as it produces many different frequencies that are perceived similarly. The many frequencies it produces are inharmonic, as there's no simple integer relationship between overtones. The lack of a strong fundamental frequency also means that you don't really need to worry about how it sounds with the rest of the ensemble - even though you can tune a snare drum up or down, it will never sound "out of tune" with the rest of the ensemble, since there's no single, easily identifiable pitch that's produced. Drum pitches are typically described in the context of the other drums in the set, rather than their relationship to pitched instruments, and drum pitches generally do not have any harmonic relationship.
That said, unpitched drums may be considered pitched depending on how they're tuned and played. A floor tom, for example, could be played gently with soft mallets to bring out the fundamental frequency or harmonic vibrational modes better (similar to how one plays timpani), rather than simply striking it with a hard stick. There won't be a hard line between pitched and unpitched, as it'll depend on the perception of the fundamental frequency and overtones. You could imagine starting with a pure pitched tone and progressively adding inharmonic overtones - the note will seem more and more non-pitched, but it'll be a fairly continuous transition from pitched to non-pitched.
EDIT: Thanks for the many comments on fundamental frequency and harmonics. Ultimately, the non-pitched nature of a drum comes its many vibrational modes and how those modal frequencies are related. Below is a figure of the first eight vibrational modes of a circular drum. The numbers in parentheses show the number of non-moving nodes in the angular and radial coordinates, respectively, while red and green show opposite directions of motion of the drum head (from this interesting page about drum physics). The value of f denotes the modal frequency, which is the pitch of that particular vibrational pattern. When striking a drum, many more of these vibrational patterns occur at the same time, each contributing to the overall sound of the drum.
Every mode is characterized by a modal frequency, which can be expressed as a multiple of the fundamental frequency (the entire drum head oscillating up and down). Most modal frequencies of the drum aren't related in a manner pleasing to the ear, so there is no discernible pitch for most drums. Drums with pitch qualities, like timpani or pitched toms, excite particular modes that are related in a more "musical" way, so they are perceived as having pitch.
A string's vibration has only one dimension instead of two, and its vibrational modes have modal frequencies related in a much simpler manner than a two-dimensional drum head. That's why there's no such thing as a non-pitched violin.
Beyond questions of harmonic strength, there are also questions of pitched stability. Some synthesized "percussion" instruments are almost pure sine waves, but come across as unpitched because their pitch is constantly changing. Even a 10ms snippet of a 1000-2000Hz tone can be perceived as pitched if its frequency is constant for the entire duration. A 100ms percussive effect whose pitch starts at 1500Hz and drops to 1000Hz (a rate of about five octaves/second) before decaying to nothing, however, will not be perceived as having a distinct pitch, even if it lingers on the final frequency for 10ms.
If one can pluck a guitar string hard enough without it breaking, the part of the attack may be over a semitone sharp, but guitars aren't plucked that hard in normal use, and even if a guitar is plucked that hard it will sustain for a long time with a relatively stable pitch. Drums, however, are often struck hard enough that their initial pitch is quite sharp, but don't have enough sustain to stabilize on a discernible pitch afterward. A drum might be heard as having a distinct pitch if it were played softly enough to avoid the sharp attack, but most drums have an ambiguous pitch during their attack, and their tail is too short to establish a pitch identity of its own.