Check it out in the reference section on this site.
But the idea is if you go from cin to getline at any time you need to clear (in this case by ignoring everything up to '\n' )the stream because there might be extra characters in the stream left over after the cin 'grabs' enough to supply your variable a. What is leftover after that is 'grabbed' by the next input instruction, in this case getline, and that messes things up.