What does it mean for a function to have frequencies?
I understand that "to have frequencies" can be misleading. This is a shorthand for "having non-zero energy or amplitude at two (specific) frequencies". Rephrased, for the cosine: when a  cosine signal is represented in the frequency domain, it has two non-zero components at frequencies $\pm \omega$, and the other values anywhere on the frequency axis have zero amplitude. Or: its frequency spectrum has only two non-zero values.

Frequency in signal processing often refers to a domain of analysis well-suited to certain signals and systems (linear systems for instance). With Fourier analysis, such signals can be represented as a weighted sum of sines or cosines, and essentially the frequencies a signal has is directly  related to the number of sines/cosines with non-zero weight in the sum. One could be more precise, depending on which type of signal and Fourier transformation one is talking about (discrete/continuous). 

The concept of frequency is somehow independent on the signal, just like the time, and time and frequency are interlinked via Fourier transforms. So "having frequencies" by itself has no meaning for a signal, just as "having time". But a signal can be described with either amplitudes in the time domain, or amplitudes in a frequency domain.

In that sense, whenever a Fourier transform is properly defined for a signal (integrability, etc.), and there is at least one non-zero value, the signal "has frequencies". 

So, most signals you will meet have frequencies, except the zero signal, and those whose Fourier transform cannot be defined correctly. As you might see later in signal processing lectures, one often uses "having frequencies" in a loose sense, meaning "above a certain threshold" instead of being simply non-zero, as in DSP practice, it is rare to have exactly zero values (finite signals, approximations, etc.)