Thanks in advance for reading. I'm new to these boards so I hope it's alright that my first post is a question.
Generally I use cin.get(); to pause a console application right before it ends, so that I can see what I've done without using cmd.exe to exec my program.
Today though, I tried my hand at classes, and for some reason if I don't cin.ignore(); after every input instance in the program, the program runs and then quits, 'ignoring' my cin.get(); at the end.
The program is posted below with the cin.ignore();'s commented out. I was just wondering if anyone can tell me WHY I need cin.ignore(); just because a class exists somewhere in the program? Is there a better way to do it?
PS: I'm using Visual C++ .net 2003 Standard, creating a new blank and empty win32 console application and right clicking "source files" and choosing "add>add new item" which is a .cpp file.
using namespace std;
DayOfYear today, birthday;
cout << "Today's Date:\n\n"
<< "Please enter the current month as a number: ";
cin >> today.month;
cout << "And the day. What day is it? ";
cin >> today.day;
cout << "Birthdate:\n\n"
<< "Enter your birthmonth as a number: ";
cin >> birthday.month;
cout << "And last, enter the day you were born: ";
cin >> birthday.day;
cout << "Today's date is ";
cout << "Your birthday is ";
if (today.month == birthday.month && today.day == birthday.day)
cout << "Happy Birthday!\n";
else cout << "Happy Unbirthday!\n";
cout << "month = " << month << ", day = " << day << endl;
EDIT: I just built it with the ignores commented out, but at the end a cin.ignore(); after the final cin.get(); and it has the same effect (the program pauses). So now I'm more confused than ever.