I figured it out by changing cin >> eventName2; to getline(cin, eventName2); . However, I'd still like to know why the cin doesn't work?
I'm trying to make a program that declares objects inside classes. For some reason when I try to do this with an event called "Birthday" or "Halloween" it works fine. The problem occurs when I enter an event that has a space in it like "My Birthday" or "Halloween Party". Suddenly the program will ignore the cin >> month and jump straight into the while loop, and for some reason it also skips the user input there and causes an infinite loop of my error message. Can anyone tell me why this is happening. I tried to debug it, and I'm sure there's a way I could use getline. The problem is I've completely forgotten how to use getline (I've only been coding for 3 months or so). I've been staring at this for hours and it's starting to look like gibberish, so I figured I'd ask you guys.
The >> operator stops reading from the input buffer when he encounters a space. When you enter "My Birthday" eventName is set to "My" and then your program moves to the next cin >> statement with the input buffer holding "Birthday". To fix this, get your string using getline, like this: getline(cin,eventName,'\n');
EDIT: Oh, I just saw that you knew that already...