Category : Files from Magazines
Archive   : CUJ9201.ZIP
Filename : 1001126A

 
Output of file : 1001126A contained in archive : CUJ9201.ZIP
#include
#include

// Crude date class to demonstrate
// customized stream I/O -- no error checking attempted

class date
{
unsigned int year; // 0-99
unsigned int mon; // 1-12
unsigned int day; // 1-31
// Allow the I/O stream operators to access the private members
// of the date class. You can't define these as members
// because the first argument is a stream, not a date.
friend ostream & operator <<(ostream &s,date dt);
friend istream & operator >>(istream &s,date &dt);
public:
// constructor
date(int _mon=1,int _day=1,int _year=0)
{ mon=_mon; day=_day; year=_year; }
};

// Output a date as: MM/DD/YY
// No attempt was made to pad the elements with zeros
ostream & operator <<(ostream &s,date dt)
{
s << dt.mon << "/" << dt.day << "/" << dt.year;
return s;
}

// Input a date in the format: MM/DD/YY -- allow any character
// to seperate the elements (i.e., MM-DD-YY, MM,DD,YY, etc.)
// Notice that the date is a reference (&dt) so we modify
// the actual date -- not a copy passed by value.
istream & operator >>(istream &s,date &dt)
{
int m,d,y;
char dummy; // this char holds the seperator
s >> m >> dummy >> d >> dummy >> y;
dt.mon=m;
dt.day=d;
dt.year=y;
return s;
}

// Simple demo for dates. Notice how the stream I/O operators
// have been overloaded to accept the date class.
main()
{
date jan1(1,1,70);
date bday;
cout << "Enter your birthday (MM/DD/YY): ";
cin >> bday;
cout << "The first date is " << jan1 << "\n";
cout << "Your birthday is " << bday << "\n";
cout << 1;
}
// End of File


  3 Responses to “Category : Files from Magazines
Archive   : CUJ9201.ZIP
Filename : 1001126A

  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/