Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. class Date
  2. {
  3. public:
  4. date(); //The constructor with 0 arguments should set the date to January 1,1900.
  5. date(int, int, int); //The constructor with three int arguments should set the date based on the values of these arguments.
  6. date(string, int , int); //The constructor with a string and two int arguments should use the string to set the value of month (1 for “January”, and so on).
  7.  
  8. void displayMonth(); // Member function displayMonth displays the month as a string
  9.  
  10.  
  11.  
  12. private:
  13. int day;
  14. int month;
  15. int year;
  16. string month_names [12] = {"January","February","March","April","May","June","July", "August","September","October","November","December"};
  17.  
  18. };
  19.  
  20.  
  21. //implementation
  22.  
  23. Date::date()
  24. {
  25. day = 1;
  26. month = 1;
  27. year = 1900;
  28. }
  29.  
  30.  
  31. Date::date(int Day, int Month, int Year)    date ( 1, 1, 1996)
  32. {
  33. day = Day;     month = Month;   year = Year;
  34. }
  35.  
  36. Date::date(int day , string Month, int year )
  37. {
  38.  
  39. for(int i = 0; i < 12; ++i)
  40. {
  41. if(month_names[i] == month)
  42. {
  43. Month = i;
  44. }
  45. }
  46. cout<<month_names[Month];
  47. }
  48.  
  49.  
  50. void displayMonth()
  51. {
  52.     cout<<month_names[]
  53. }
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. #include <iostream>
  62. using namespace  std;
  63. int main()
  64. {
  65. int day, month, year;
  66. cout<<"Enter the number of day, month, year";
  67. cin>>day>>month>>year;
  68. if(day>31) break;
  69. if(month>12) break;
  70. if (year<1900||year>2010) break;
  71.  
  72. Date date(day, month, year);  //constructor
  73.  
  74.  
  75.  
  76.  
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement