Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- class Date
- {
- private:
- int day;
- string Month;
- int Year;
- public:
- void Input_Date()
- {
- cout<<"Enter day\n";
- cin>>day;
- cout<<"Enter Month\n";
- cin>>Month;
- cout<<"Enter year\n";
- cin>>Year;
- try
- {
- if (day == 0)
- {
- throw 1;
- }
- if (Month==" ")
- {
- throw 2;
- }
- Year=sizeof(Year);
- if (Year<4)
- {
- throw 3;
- }
- }
- catch(int i)
- {
- if (i==1){
- cout << "Ошибка №" << i << " - значение дня должно быть больше 0!" << endl;}
- if (i==2)
- {
- cout << "Ошибка №" << i << " - название месяца должно быть строкой,а не числовым значением!" << endl;
- }
- if (i==3)
- {
- cout << "Ошибка №" << i << " - значение должно иметь в себе больше 3 символов!" << endl;
- }
- }
- }
- };
- int main() {
- Date d1;
- d1.Input_Date();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement