- 论坛徽章:
- 0
|
- class Date{
- int month;
- int day;
- int year;
- int hour;
- int minute;
- int second;
- // and the get set function
- }
- // the iostream
- // format: mm/dd/yyyy hh:mm:ss \n
- //mm/dd/yyyy hh:nn:ss \n
- ostream &operator<<(ostream& out, const Date& date){
- out << date.getMonth() << "/"
- << date.getDay() << "/"
- << date.getYear() << " "
- << date.getHour() << ":"
- << date.getMinute() << ":"
- << date.getSecond() << " " << endl;
- }
- istream &operator>>(istream& in, Date& date){
- char temp;
- int month, day, year, hour, minute, second;
- in >> month >> temp
- >> day >> temp
- >> year >> temp
- >> hour >> temp
- >> minute >> temp
- >> second >> temp;
- date.setMonth(month);
- date.setDay(day);
- date.setYear(year);
- date.setHour(hour);
- date.setMinute(minute);
- date.setSecond(second);
- cout << endl;
- }
复制代码
这样子为什么不行呢 呵呵 求助
[ 本帖最后由 DraculaW 于 2007-1-10 14:06 编辑 ] |
|