gosuodin

nhap ngay class

May 27th, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include<iomanip>
  4. using namespace std;
  5.  
  6. class Nhapday
  7. {
  8. public:
  9. Nhapday();
  10. void set_day(int=1 ,int=1 , int=1 );
  11. int get_day();
  12.  
  13. private:
  14. int day;
  15. int m;
  16. int y;
  17.  
  18. };
  19. Nhapday::Nhapday() {
  20.  
  21. }
  22. void Nhapday::set_day(int day,int m, int y) {
  23. if ((day > 0) && (day < 32)) {
  24. this->day = day;
  25. }
  26. if ((m > 0) && (m< 13)) {
  27. this->m = m;
  28. }
  29. if ((y > 0)) {
  30. this->y=y;
  31. }
  32.  
  33.  
  34. }
  35. int Nhapday::get_day() {
  36. cout <<setw(2) << setfill('0')<<day
  37. << "/" << setw(2) << setfill('0') <<m
  38. << "/" << setw(4) << setfill('0')<< y;
  39. return 0;
  40. }
  41.  
  42.  
  43.  
  44. int main() {
  45. Nhapday d;
  46.  
  47. d.set_day( 6, 3);
  48. d.get_day();
  49.  
  50.  
  51.  
  52. system("pause");
  53. }
Add Comment
Please, Sign In to add comment