fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Date
  5. {
  6. public :
  7. Date(); // default constructor prototype
  8. Date(int, int, int); // parameterized contructor prototype
  9.  
  10. void setDate(int,int,int); //behavior
  11. void setMonth(int); // mutator function prototype
  12. void setDay(int); // mutator function prototype
  13. void setYear(int); // mutator function prototype
  14.  
  15. void displayDate(); //behavior
  16.  
  17. private:
  18. int month; //attributes
  19. int day; //attributes
  20. int year; //attributes
  21. };
  22.  
  23. // default constructor
  24. Date::Date()
  25. {
  26. month = 1;
  27. day = 01;
  28. year = 2012;
  29. }
  30.  
  31. void Date::setDate(int _month, int _day,int _year)
  32. {
  33. month = _month; //instance
  34. day = _day; //instance
  35. year = _year; //instance
  36. }
  37.  
  38. void Date::displayDate()
  39. {
  40. cout<<month<<'-'<<day<<'-'<<year;
  41. }
  42.  
  43. void Date::setMonth(int _month)
  44. {
  45. month = _month;
  46. }
  47.  
  48. void Date::setDay(int _day)
  49. {
  50. day = _day;
  51. }
  52.  
  53. void Date::setYear(int _year)
  54. {
  55. year = _year;
  56. }
  57.  
  58.  
  59. main()
  60. {
  61. Date anvsy;
  62. int month, day, year;
  63. cout<<"Please Enter the information for your anniversary" << endl << endl;
  64.  
  65. cout << "Enter the month: ";
  66. //cin >> month;
  67. month = 3;
  68. anvsy.setMonth(month);
  69.  
  70. cout<<"Enter the day: ";
  71. //cin>> day;
  72. day = 7;
  73. anvsy.setDay(day);
  74.  
  75. cout<<"Enter the year: ";
  76. //cin>> year;
  77. year = 2015;
  78. anvsy.setYear(year);
  79.  
  80. cout<<endl;
  81. cout<<"The Anniversary Date is on ";
  82. anvsy.displayDate();
  83.  
  84. return EXIT_SUCCESS;
  85. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Please Enter the information for your anniversary

Enter the month: Enter the day: Enter the year: 
The Anniversary Date is on 3-7-2015