嗨,我按顺序输入了以下几行:
Date, Time, Price, Volume, Value,
日期采用DD / MM / YY格式,时间采用HH / MM / SS AM / PM格式,而价格,数量和价值是用逗号分隔的数字。
此输入有4000行,“ value”逗号后面有时会出现一个共享代码,例如“ CX”或“ NXXT”。
我的程序无法处理此问题并崩溃。
我需要的是一种忽略“值”后逗号以外的内容并继续阅读下一行的方法。 这将在“ Shares”类中。
以下是我班上的输入流:
类:“日期”
istream & operator >> (istream & input, Date & C) /// An input stream for the day, month and year
{
char delim;
input >> C.day >> delim >> C.month >> delim >> C.year;
return input; /// Returning the input value
}
上课时间'
istream & operator >> (istream & input, Time & C) /// An input stream for the hour minutes and seconds
{
char delim;
input >> C.hour >> delim >> C.minute >> delim >> C.second;
getline(input,C.ampm,',');
return input; /// Returning the input value
}
类别“股份”
istream & operator >> (istream & input, Shares & C) /// An input stream for the day, month and year
{
char delim;
input >> C.price >> delim >> C.volume >> delim >> C.value >> delim;
return input; /// Returning the input value
}