得到一个运行时错误,上面写着“在抛出std::bad_alloc
.
do
{
getline(in_stream, tempstr1);
itemNumb.push_back(tempstr1);
getline(in_stream, tempstr2);
itemNumb.push_back(tempstr2);
in_stream >> tempdoub;
itemCost.push_back(tempdoub);
in_stream >> tempint;
itemQuant.push_back(tempint);
index++;
} while (! in_stream.eof());
in_stream.close();
编辑:应该已经澄清,itemNumb
并且itemName
是字符串向量,itemCost
是双向量,并且itemQuant
是整数向量。tempstr1
和 2 是字符串,tempdoub
是双精度数,tempint
是整数。