⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newclock.h

📁 C++编成数据结构与程序设计方法 D.S.Malk编著
💻 H
字号:
//Header file newClock.h

#ifndef H_newClock
#define H_newClock

#include <iostream>

using namespace std;

class clockType
{
    friend ostream& operator<<(ostream&, const clockType&);
    friend istream& operator>>(istream&, clockType&);

public:
   void setTime(int hours, int minutes, int seconds);
      //Function to set the member variables hr, min, and sec.  
      //Postcondition: hr = hours; min = minutes; sec = seconds

   void getTime(int& hours, int& minutes, int& seconds) const;
      //Function to return the time.
      //Postcondition: hours = hr; minutes = min; seconds = sec

   clockType operator++();    
      //Overload the pre-increment operator.
      //Postcondition: The time is incremented by one second.

   bool operator==(const clockType& otherClock) const; 
      //Overload the equality operator.
      //Postcondition: Returns true if this time is equal to 
      //               otherTime, otherwise it returns false.

   bool operator!=(const clockType& otherClock) const; 
      //Overload the equality operator.
      //Postcondition: Returns true if this time is equal to 
      //               otherTime, otherwise it returns false.

   bool operator<=(const clockType& otherClock) const;
      //Overload the less than or equal to operator.
      //Postcondition: Returns true if the time is less than 
      //               or equal to otherTime, otherwise it 
      //               returns false.

   bool operator<(const clockType& otherClock) const;
      //Overload the less than or equal to operator.
      //Postcondition: Returns true if the time is less than 
      //               or equal to otherTime, otherwise it 
      //               returns false.

   bool operator>=(const clockType& otherClock) const;
      //Overload the less than or equal to operator.
      //Postcondition: Returns true if the time is less than 
      //               or equal to otherTime, otherwise it 
      //               returns false.

   bool operator>(const clockType& otherClock) const;
      //Overload the less than or equal to operator.
      //Postcondition: Returns true if the time is less than 
      //               or equal to otherTime, otherwise it 
      //               returns false.

   clockType(int hours = 0, int minutes = 0, int seconds = 0);  
      //Constructor to initialize the object with the values 
      //specified by the user. If no values are specified,
      //the default values are assumed.
      //Postcondition: Returns: hr = hours; min = minutes; 
      //                        sec = seconds;

private: 
    int hr;  //variable to store the hours
    int min; //variable to store the minutes
    int sec; //variable to store the seconds
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -