ignore函數

istream &operator>>(istream& stream, Date& date)
{
 int month,day,year,hour,minute,second;
 
//ignore(len,ch);表示跳過len個字符或者直到ch字符爲止;
 //將len設爲10(>1)增加容錯性。
 stream>>month;
  stream.ignore(10,'/');
 stream>>day;
  stream.ignore(10,'/');
 stream>>year;
  stream.ignore(10,' ');
 stream>>hour;
  stream.ignore(10,':');
 stream>>minute;
  stream.ignore(10,':');
 stream>>second;
  date.setDay(day);
  date.setHour(hour);
  date.setMinute(minute);
  date.setMonth(month);
  date.setYear(year);
  date.setSecond(second);
 return stream;
}

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章