time.h

来自「一本语言类编程书籍」· C头文件 代码 · 共 25 行

H
25
字号
// Exercise 19.3a Time.h
// Definition of Time class File

#ifndef TIME_H
#define TIME_H
#include <iostream>

class Time {
  public:
    Time(): hours(0),minutes(0), seconds(0){}          // Default constructor 
    Time(int h, int m, int s);                         // Constructor
    int getHours()const { return hours; }
    int getMinutes()const { return minutes; }
    int getSeconds()const { return seconds; }

    friend std::istream& operator>> (std::istream& in, Time& rT);  // Friend extraction operator
  private:
    int hours;
    int minutes;
    int seconds;
};

std::ostream& operator <<(std::ostream& out, const Time& rT); // Overloaded operator declaration

#endif //TIME_H

⌨️ 快捷键说明

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