Category : C++ Source Code
Archive   : CPPTUT.ZIP
Filename : TIME.H

 
Output of file : TIME.H contained in archive : CPPTUT.ZIP
// Chapter 6 - Program 10

// This is probably the minimum usable time class, but is intended as
// an illustration of a class rather than to build an all inclusive
// class for future use. Each student can develop his own to suit
// his own taste.

#ifndef TIME_H
#define TIME_H

class time_of_day {
protected:
int hour; // 0 through 23
int minute; // 0 through 59
int second; // 0 through 59
static char format; // Format to use for output
static char out_string[25]; // Format output area

public:
// Constructor - Set time to current time and format to 1
time_of_day(void);
time_of_day(int H) {hour = H; minute = 0; second = 0; };
time_of_day(int H, int M) {hour = H; minute = M; second = 0; };
time_of_day(int H, int M, int S) {hour = H;
minute = M; second = S; };

// Set the time to these input values
// return = 0 ---> data is valid
// return = 1 ---> something is out of range
int set_time(void);
int set_time(int hour_in);
int set_time(int hour_in, int minute_in);
int set_time(int hour_in, int minute_in, int second_in);

// Select string output format
void set_time_format(int format_in) { format = format_in; };

// Return an ASCII-Z string depending on the stored format
// format = 1 13:23:12
// format = 2 13:23
// format = 3 1:23 PM
char *get_time_string(void);

};

#endif


  3 Responses to “Category : C++ Source Code
Archive   : CPPTUT.ZIP
Filename : TIME.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/