Sure. Create a monitor object of some sort that monitors the microphone input. When it detects a change in frequency, it modifies the value in question. This would probably be in it own thread.
Another thread would watch the value, and when it changes, perform the other action.
Also, you could just do a single-threaded program where the monitor object performs the action.
There are lots of possibilities of how to do what you want. Why not start by learning the basics of the language first. When you get comfortable with C++, then work on just monitoring the microphone input and maybe printing out the measured frequencies. Then build on that.
Normally, you get time-domain amplitude samples from a microphone. You need to convert this into the frequency domain yourself (for example, using the FFT). It would be a cool project, but as doug4 mentioned, it might be hard for a beginner.