Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool read (const string& ageStr, int& age, bool result)
- {
- cout << ageStr;
- cin >> age;
- if(cin.fail())
- {
- cin >> result;
- cin.clear();
- result = false;
- }
- else
- {
- result = true;
- }
- return result;
- }
- bool read(const string& gpaStr, double& gpa, bool result)
- {
- string junk;
- cout << gpaStr;
- cin >> gpa;
- if(cin.fail())
- {
- cin.clear();
- cin >> junk;
- result = false;
- }
- else
- {
- cin.ignore(1024, '\n');
- result = true;
- }
- return result;
- }
- bool read(const string& nameStr, string& name, bool result)
- {
- cout << nameStr;
- getline(cin, name);
- if(cin.fail())
- {
- result = true;
- }
- return result;
- }
- bool read(char& ch, char dot)
- {
- cin.get(ch);
- if(ch == dot)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement