Category : C Source Code
Archive   : ANSICPP.ZIP
Filename : EX07005.CPP

 
Output of file : EX07005.CPP contained in archive : ANSICPP.ZIP
// ex07005.cpp
// Constructor conversion function
#include
#include

class Date {
int mo, da, yr;
public:
Date() {} // null constructor
Date(time_t); // constructor conversion function
void display(void);
};
// ----- member function to display the date
void Date::display()
{
cout << mo << '/' << da << '/' << yr;
}
// ------ constructor conversion function
Date::Date(time_t now)
{
struct tm *tim = localtime(&now);
da = tim->tm_mday;
mo = tim->tm_mon + 1;
yr = tim->tm_year;
}

main()
{
time_t now = time((time_t *)NULL); // today's date and time
Date dt(now); // invoke the conversion constructor
dt.display(); // display today's date
}


  3 Responses to “Category : C Source Code
Archive   : ANSICPP.ZIP
Filename : EX07005.CPP

  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/