Advertisement
Guest User

Untitled

a guest
Oct 30th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. //Time Class Definition with const member functions
  2. #ifndef TIME_H
  3. #define TIME_H
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. class Time
  9. {
  10. friend ostream& operator<<(ostream&, const Time&);
  11. friend istream& operator>>(istream&, Time&);
  12.  
  13. private:
  14. int hour; //0-23 (24 hour clock format)
  15. int minute; //0-59
  16.  
  17. public:
  18. //default constructor
  19. Time(int = 0, int = 0);
  20.  
  21. //set functions - not const since they modify private data
  22. //The & return type enables cascading
  23. Time& setTime(int, int);
  24. Time& setHour(int);
  25. Time& setMinute(int);
  26.  
  27. //get functions - (normally always declared const)
  28. int getHour() const;
  29. int getMinute() const;
  30.  
  31. //print functions - (normally always declared const since they do not modify private members, merely inspect
  32. void printUniversal() const;
  33. void printStandard()const;
  34.  
  35. // void operator= (const Time&);
  36.  
  37. //compare overloaded functions
  38. bool operator== (const Time&);
  39. bool operator!= (const Time&);
  40.  
  41. bool operator<= (const Time&);
  42. bool operator< (const Time&);
  43.  
  44. bool operator>= (const Time&);
  45. bool operator> (const Time&);
  46.  
  47. };
  48.  
  49. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement