Category : C++ Source Code
Archive   : TEACHCPP.ZIP
Filename : TIMES.H
// Header file to redefine the time classes with virtual functions
// ---------- times.h
#ifndef TIMES_H
#define TIMES_H
#include
#include
//
// A Time Class
//
class Time {
int hours, minutes, seconds;
public:
Time(int hr, int min, int sec)
{ hours = hr; minutes = min; seconds = sec; }
virtual void display()
{ cout << hours << ':' << minutes << ':' << seconds; }
};
//
// A TimeZone Class
//
enum timezone { gmt, est, cst, mst, pst };
char *TZ[] = { "GMT", "EST", "CST", "MST", "PST" };
class TimeZone : public Time {
protected:
timezone zone;
public:
TimeZone(int hr, int min, int sec, timezone zn)
: Time(hr, min, sec)
{ zone = zn; }
virtual void display()
{ Time::display(); cout << ' ' << TZ [zone]; }
};
//
// A DispTime Class
//
inline int adjust(int hour)
{ return hour > 12 ? hour - 12 : (hour == 0 ? 12 : hour); }
inline char makeampm(int hour)
{ return hour < 12 ? 'a' : 'p'; }
class DispTime : public TimeZone {
protected:
char ampm;
public:
DispTime(int hr, int min, int sec, timezone zn)
: TimeZone(adjust(hr), min, sec, zn)
{ ampm = makeampm(hr); }
void display() {
Time::display();
cout << ' ' << ampm << 'm';
cout << ' ' << TZ [zone];
}
};
#endif
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/