【发布时间】:2010-12-05 23:54:02
【问题描述】:
我需要重写
我想我已经包含了所有必要的部分。提前致谢。
struct Reading {
int hour;
double temperature;
Reading(int h, double t): hour(h), temperature(t) { }
bool operator<(const Reading &r) const;
};
========
ostream& operator<<(ostream& ost, const Reading &r)
{
// unsure what to enter here
return ost;
}
========
vector<Reading> get_temps()
{
// stub version
cout << "Please enter name of input file name: ";
string name;
cin >> name;
ifstream ist(name.c_str());
if(!ist) error("can't open input file ", name);
vector<Reading> temps;
int hour;
double temperature;
while (ist >> hour >> temperature){
if (hour <0 || 23 <hour) error("hour out of range");
temps.push_back( Reading(hour,temperature));
}
}
【问题讨论】:
-
你有什么问题?您是要我们为您编写函数吗?
-
重复:stackoverflow.com/questions/4362077/… 没有必要问两个相同/相似的问题。
-
你只是在重复你之前的问题:stackoverflow.com/questions/4362077/…
-
小时重要还是仅仅意味着温度?
-
请不要在标题中添加标签,也不要一遍又一遍地问同一个问题。在答案上使用 cmets 与他们的作者互动并编辑您的问题以添加更多详细信息。