< < 연산자를 다시 작성해야 시간 (int) 및 온도 (double)에 대한 값을 계산할 수 있습니다.<< 연산자 int 및 double 값을 계산하도록 다시 쓰기
모든 필수 섹션이 포함되어 있다고 생각합니다. 미리 감사드립니다.
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));
}
} 표준 : : cout과 같은
이 숙제인가 할 수 있습니까? –
무엇이 당신의 질문입니까? 우리에게 당신을 위해 당신의 기능을 쓰라고 하시겠습니까? – Gabe
중복 : http://stackoverflow.com/questions/4362077/c-operator-rewrite-to-cout-int-and-double-values 동일/유사한 질문 2 개를 요청할 필요가 없습니다. –