#include #include using namespace std; class date { public: date(const char *NewD); date(int NewY, int NewM, int NewD); date(); void show(); private: int y, m, d; }; date::date(int NewY, int NewM, int NewD) : y(NewY), m(NewM), d(NewD) {} date::date(const char *NewD) { sscanf(NewD, "%d-%d-%d", &y, &m, &d); } void date::show() { cout << y << '-' << m << '-' << d << endl; } date::date() : y(1970), m(1), d(1){} int main() { date d1, d2(2011, 3, 8), d3("2011-03-19"); d1.show(); d2.show(); d3.show(); }